Response.Redirect results in "Object moved to here"
This may caused by putting the Response.Redirect()
method in try-catch
block. The solution I came along was to End the response virtually by flushing a redirect header to the client. take a look:
HttpResponse Response = HttpContext.Current.Response;Response.StatusCode = 301; Response.StatusDescription = "Moved Permanently";Response.RedirectLocation = "YourRedirectionUrlHere.aspx";Response.Flush();
I've just come across a case where this is happening. Turns out we had some code that effectively did:
if (condition){ Response.Redirect(page1);}Response.Redirect(page2);
Obviously the person who wrote this (a good while ago fortunately) didn't realise that a Response.Redirect does not, by default, end the thread.
I've no idea what the consequences of doing this are but a fiddler trace of this happening looks to show a corrupt redirect. This might be a co-incidence of course but this is the only place we've seen this issue.