G
Guest
I'm trying to write a log file that captures the referring url if the request is a new session, and captures a querystring value if the user is browsing between pages on the website.
When using the code below, I get the following error...
"System.NullReferenceException: Object reference not set to an instance of an object"
******************************************
protected void Session_Start(Object sender, EventArgs e)
{
System.Uri refURL = Context.Request.UrlReferrer;
if(refURL != null)
{
Context.Session.Add("referingURL", refURL.ToString());
}
}
protected void Application_BeginRequest(Object sender, EventArgs e)
{
string refPage = Context.Request.QueryString.Get("Page");
if(refPage != null)
{
Context.Session.Add("referingPage", refPage.ToString());
}
}
******************************************
Does anyone know what I'm doing wrong?
Thanks in advance for your help!
When using the code below, I get the following error...
"System.NullReferenceException: Object reference not set to an instance of an object"
******************************************
protected void Session_Start(Object sender, EventArgs e)
{
System.Uri refURL = Context.Request.UrlReferrer;
if(refURL != null)
{
Context.Session.Add("referingURL", refURL.ToString());
}
}
protected void Application_BeginRequest(Object sender, EventArgs e)
{
string refPage = Context.Request.QueryString.Get("Page");
if(refPage != null)
{
Context.Session.Add("referingPage", refPage.ToString());
}
}
******************************************
Does anyone know what I'm doing wrong?
Thanks in advance for your help!