Link to home
Start Free TrialLog in
Avatar of VBBRett
VBBRett

asked on

What am I doing wrong in my VB.net code?

I am trying to get where the referral url came from where a visitor would have came from.  So here is my code for my function:

 
Public Function Referralurl() As String

        Dim referringurl As String

        referringurl = Request.UrlReferrer.AbsolutePath

        If referringurl = Nothing Then
             referringurl = "Nothing"
        End If

        Return referringurl
    End Function

Open in new window


Immediately after I start my program, I get the error code: "Object Instance not set to an instance of an object on the line where it states the following:

Object reference not set to an instance of an object.

What can I do to fix this problem?  Thank you!
Avatar of Rajkumar Gs
Rajkumar Gs
Flag of India image

Since I am from mobile, I cannot read the code-snipplets fully. Could you please post the code as comment instead of as an attachment ?

Also specify which line is crashing.
Raj
Normally this error message triggers when an object is not instantiated.

Raj
Avatar of VBBRett
VBBRett

ASKER

Yes, here is the code:

Public Function Referralurl() As String

        Dim referringurl As String

        referringurl = Request.UrlReferrer.AbsolutePath

        If referringurl = Nothing Then
             referringurl = "Nothing"
        End If

        Return referringurl
    End Function
 
ASKER CERTIFIED SOLUTION
Avatar of Zhaolai
Zhaolai
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is this line is crashing ?
referringurl = Request.UrlReferrer.AbsolutePath

Raj
Zhaolai has posted what is in my mind first.

...= String.Empty

Raj