problem with UrlReferrer on first instance of home page

T

tony collier

Hi

I have this declaration on most of my pages for the UrlReferrer.

String referrer=Request.UrlReferrer.ToString();


This works fine apart from when the user first visits the site on the home
page, which results in the following error

"Object reference not set to an instance of an object"


if i take the above line out , navigate to another page, put the line back
in to home page and navigate back to home page it works fine. So I am
guessing that at the start of the session UrlReferrer doesn't exist until
after the first page navigation. Any ideas how I can get round this?

tia.
 
B

Boban Dragojlovic

the referrer is the page that sent you to this page, so naturally, on the
first page, you don't have a referrer

to get around it,

dim Referrer as string

if Request.URLReferrer is Nothing then
Referrer = ""
else
Referrer = Request.URLReferrer.ToString()
end if

or the equivalent in C#
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top