views:

38

answers:

2

I am doing a 301 permanent redirect from an old server to a new server. When the new server's page is hit I want to be able to determine whether the user comes from the old site and then react differently, i.e. instruct user to re-book mark the new page.

Any suggestions on how to determine if the referrer was a permanent redirect?

TIA

J

+2  A: 

The browser typically handles this sort of thing, and most browsers do not pass on a referrer when coming from a 301 permanent redirect. The RFC standard does not specify whether or not referrer information should be passed, so you can't expect that behavior.

If you are redirecting to the same primary domain, you can try a cookie value. You can also try redirecting with a special querystring, like ?from=oldsite or something along those lines in order to solve this issue.

rakuo15
Actually it is to a new domain so the cookie is out. I am going to try to figure out a way to pass a querystring but it could be difficult because the redirect is from IIS not from an originating page. Thanks
John
IIS lets you specify querystrings when implementing a redirect. If you categorically want to add the querystrings to all IIS redirects, you can do so.
rakuo15
A: 

You should be able to use this code:

string referrer = Request.UrlReferrer.ToString();

I think you can also do it this way:

string referrer = Request.ServerVariables["http_referrer"];
icemanind
Neither of these will work. I've tested both and the referrer information is not passed along.
John