none
UrlReferrer problem

    Question

  • I'm using the following simple code:

           

    Dim MyUrl As Uri = Request.UrlReferrer

            Response.Write(

    "Referrer URL Port: " & Server.HtmlEncode(MyUrl.Port.ToString()) & "<br>")

            Response.Write(

    "Referrer URL Protocol: " & Server.HtmlEncode(MyUrl.Scheme) & "<br>")

    And I'm receiving the following error:

    Object reference not set to an instance of an object.              Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.            

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

    Source Error:
    Line 53: 
    Line 54:         Dim MyUrl As Uri = Request.UrlReferrer
    Line 55:         Response.Write("Referrer URL Port: " & Server.HtmlEncode(MyUrl.Port.ToString()) & "<br>")
    Line 56:         Response.Write("Referrer URL Protocol: " & Server.HtmlEncode(MyUrl.Scheme) & "<br>")
    Line 57: 
                      

    I believe this used to work but for some reason it no longer does.  Any ideas?

    Sunday, March 20, 2016 12:51 AM

Answers