View Single Post
  #2 (permalink)  
Old February 21st, 2011, 12:51 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

You can use

Request.UrlReferrer

or

Request.ServerVariables("HTTP_REFERER")

for this. Just make sure you always check for null or empty string values as the value isn't guaranteed to be there. You only get a value when you click a link from one page to another, not when you enter an address in the address bar of the browser directly. Also, security software may strip the referrer.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
barakros (February 21st, 2011)