Wednesday, July 30, 2008

Logging HTTP Referals with ASP.NET

Logging HTTP Referals with ASP.NET:

public void Application_OnPostRequestHandlerExecute(Object sender, EventArgs e)
{
ReferralLogger rlLogger;
if (String.Empty != Request.QueryString.ToString())
// We have query parameters so we need to log those as well
// as the current page name
rlLogger = new ReferralLogger(Request.Path.ToString()+"?"
Request.QueryString.ToString(),
Request.UrlReferrer);
else
// No query string, so simply log the request and the referring URL
rlLogger = new ReferralLogger(Request.Path.ToString(),
Request.UrlReferrer);
}

And now, every time the ASP.Net engine displays a file its referral information will be stored in your database.

1 comment:

Anonymous said...

your site is very nice ...
this is very helpful and attractive.
visit for asp.net help asp.net help