Apparently,
UrlReferrer
can be null, which would always throw the exact exception you observe. The browser gives you the referral data when the user clicks the anchor with the URL of your page, but what if the user simply type its URL in the address line? The referrer would be null, so you need to take it into account.
Besides, what are you doing?! Of course,
HttpRequest.UrlReferrer
is
System.Uri
, so you can use
ToString
, but your
MyReferrer
is already the string, why are you trying to calculate
ToString
of a string? Please see:
http://msdn.microsoft.com/en-us/library/system.web.httprequest.urlreferrer.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.uri.aspx[
^].
—SA