Helpful Information
 
 
Category: ASP.NET
Request.UrlReferrer.ToString()

I'm trying to use the Request.UrlReferrer.ToString() to get the referrer. It works but if you go straight to the page, meaning Request.UrlReferrer.ToString() is nothing, I get an Object instance not set to an instance of an object error. I tried..




If Not IsPostBack Then
If Not Request.UrlReferrer.ToString() Is Nothing Then
referrer = Request.UrlReferrer.ToString()
End If
End If


I still got the same error. Any ideas?

I got it, I need to get rid of the .tostring() part. Thanks anyway ;)

in C#,you can:

if ( Request.UrlReferrer != null )
{
//do something here....
}

thanks for the advice










privacy (GDPR)