Solved

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

Posted on 2010-11-07
6
312 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 17

Accepted Solution

by:
Zhaolai earned 500 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now