UrlReferer

  • Thread starter Thread starter Daniel Groh
  • Start date Start date
D

Daniel Groh

Hi, I'm trying this line:

if(Request.ServerVariables["HTTP_REFERER"]!="AddUser.aspx")
{
Response.Redirect("AddUser.aspx");
}

But it's not working...I tryed also Request.UrlReferer and didn't work too!

Does someone has examples ?
 
Daniel said:
Hi, I'm trying this line:

if(Request.ServerVariables["HTTP_REFERER"]!="AddUser.aspx")
{
Response.Redirect("AddUser.aspx");
}

But it's not working...I tryed also Request.UrlReferer and didn't
work too!

UrlReferer is a property that represents HTTP_REFERER -- no need to
hang on to 10 year old CGI style programming practices ;-)

But there's no guarantee that you'll ever receive a Referer, because
this header can be stripped off or manipulated by proxies.

Cheers,
 
Daniel,

firstly Request.UrlReferrer is not a string to do a
Request.UrlReferrer.ToString() to convert it to string
(check to make sure its not null before)

once you have a string use String.IndexOf() to fin to find if the page
exists in the url referrer string.

HTH

Regards,

Hermit Dave
http://hdave.blogspot.com
 
Back
Top