| re: problem with UrlReferrer on first instance of home page
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#
"tony collier" <melakka@hotmail.com> wrote in message
news:Xns9485DFF5249FAmelakkahotmailcom@140.99.99.1 30...[color=blue]
> 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.
>
>[/color] |