1
votes

Here is my situation:

Page1.aspx redirects to Page2.aspx which does some processing (does not display to the user) and then redirects to Page3.aspx which checks the ServerVariables["HTTP_REFERER"] or Request.UrlReferrer.

I understand that the referring information can sometimes be blank and can't be entirely relied upon; however the ServerVariables["HTTP_REFERER"] or Request.UrlReferrer on Page3.aspx is showing Page1.aspx instead of Page2.aspx which I would have expected.

Does the referring information only get set if the page displays to the user?

Redirecting is done using Response.Redirect in order to change the URL in the address bar of the browser.

2

2 Answers

5
votes

because the http redirect instructs the browser to find the page in a new place, so the browser assumes it's still dealing with the original request on page1.aspx, and hence sends that through as the referer :)

it's worth bearing in mind that the referer is just sent through from the browser and hence cannot be trusted 100% - some proxies remove it altogether for example.

0
votes

I believe part of it depends on how the page is being redirected: Server.Transfer or Response.Redirect.

http://haacked.com/archive/2004/10/06/responseredirectverseservertransfer.aspx