Forum Moderators: open

Message Too Old, No Replies

ASP.net - code to display the referrer

Here we go again

         

chris_f

6:06 pm on Jul 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My apologise again. I've not been feeling well and as such seem to have lost the ability to program (or see the bleeding obvious).

Can someone please post the code to bring back the referrer. Every time I try it I get the 'Object reference not set to an instance of an object'.

FYI,
I have tried the following:
1. Referrer = Request.UrlReferrer.AbsolutePath.ToString
2. Referrer = Request.ServerVariables("http_referrer")
3. Referrer = Request.UrlReferrer.ToString()

Can you please include any needed namespaces.

Thanks in advanced
Chris 'losing my mind' Felstead.

Xoc

7:47 pm on Jul 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The thing to do in such cases is to get into the Debugger in Visual Studio. In your case, I think you'll find that Request is just a variable. In the case of ASP.NET code, you shouldn't need to define Request, as the code-behind should be inherited from System.Web.UI.Page.

The Page class defines Request and provides it to your page. If you haven't inherited from System.Web.UI.Page, then Request won't be defined.

chris_f

8:11 pm on Jul 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Xoc,

System.Web.UI.Page is already inherited in my code. Here's the code if it help. Boy am I owing you guys a few favor's. This is the last problem though, I PROMISE.

Dim Referrer As String

Referrer = Request.UrlReferrer.AbsolutePath.ToString

Response.Write(Referrer)

error message


Dim Referrer As String

Referrer = Request.ServerVariables("http_referrer")

Response.Write(Referrer)

Returns a blank page


Dim Referrer As String

Referrer = Request.UrlReferrer.ToString()

Response.Write(Referrer)

error message

Thanks again.
Chris.

chris_f

8:55 am on Jul 13, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Any ideas?

chris_f

1:33 pm on Jul 13, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok. A good night's sleep is all I needed. It's working now.

[big]Xoc, I would like to extend my own personal thanks to you. If you going to the pub conference then I think you deserve two rounds on me :).[/big]

Chris.