views:

977

answers:

2

We have a simple Response.Redirect on a page that is working inconsistently (IIS 6.0). Most of the time it redirects correctly, but we're getting some users that are complaining that instead of redirecting, they are getting the "302 Object moved to here" page. The page displays the header information with the correct location. If you click "here," it redirects to the correct page.

Any ideas why it would display the 302 message sporadically?

A: 

You could try to manually set the status code of the response to 301. Here is some borrowed code that should help you out:

Response.StatusCode = 301; 
Response.StatusDescription = "Moved Permanently";
Response.RedirectLocation = "RedirectionPage.aspx"; 
Response.End()

You could also use as a last-ditch effort Server.Transfer() or output a simple script that sets the window's location to the new url.

Page.ClientScript.RegisterStartupScript(Page.GetType
"RedirectScript", "window.location.href='RedirectionPage.aspx'", true);

Although I wonder how well their browsers will do with javascript if they're not respecting the original redirection.

Do you have any information on the browsers these people are using?

Dave L
The specific example I know for sure was Firefox 3.0.10. But, I don't know if it's affecting other browsers.
+1  A: 

302 IS the code response.redirect returns. I also saw a note to do a client-side

window.location = 'url'

but it does sound like a browser setting.

n8wrl