Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-11-07
6
Medium Priority
?
323 Views
Last Modified: 2012-06-27
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!
0
Comment
Question by:VBBRett
  • 4
6 Comments
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34080823
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
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34080828
Normally this error message triggers when an object is not instantiated.

Raj
0
 

Author Comment

by:VBBRett
ID: 34080841
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
 
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Accepted Solution

by:
Zhaolai earned 2000 total points
ID: 34080846
Try this:

    Public Function Referralurl() As String

        Dim referringurl As String = String.Empty
        If Request.UrlReferrer IsNot Nothing Then
            referringurl = Request.UrlReferrer.AbsolutePath
        End If

        Return referringurl
    End Function

Open in new window

0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34080851
Is this line is crashing ?
referringurl = Request.UrlReferrer.AbsolutePath

Raj
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34080880
Zhaolai has posted what is in my mind first.

...= String.Empty

Raj
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question