Trying to check if urlreferrer is null

Viewed 10365

I am using the following line of code to check if the UrlReferrer is null

@if (Request.UrlReferrer.AbsolutePath == null)

It just gives me an error of:

System.NullReferenceException: Object reference not set to an instance of an object.

I'm new to asp and have hunted around but can't seem to find anything that will answer my question. The thing that confuses me is if I replace null like so:

@if (Request.UrlReferrer.AbsolutePath == "/Home")

...and the AbsolutePath is indeed /Home, the code works fine, surely I'm asking for the same thing here but with null?

2 Answers
Related