Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Response.Redirect results in "Object moved to here"

I'm working on a C# ASP.NET page that normally ends up redirecting to a "file:" URL. This seems to work fine the majority of the time, in the majority of circumstances, but occasionally (and, on my test system, apparently always) instead of a redirect to a file I get a page with the text "Object moved to here", where "here" is a link to the file that I was trying to redirect to, but with four slashes after the colon instead of two (i.e. "file:////testserver/docs/testdoc.doc")

This is normally accompanied by a "System.Threading.ThreadAbortException: Thread was being aborted" message.

I've looked for a solution elsewhere and found out some interesting stuff about Response.Redirect causing ThreadAbort exceptions, but that doesn't seem to be the fundamental problem - it seems to me that the actual problem is the "Object moved to here" message, which causes the exception to be thrown.

Anybody got any suggestions why I'm getting that...?

EDIT: Forgot to mention I'm running Firefox (3.5.7) with IE Tab, so was about to mention that when I thought I'd better try it in IE, and voila - it works in IE (7).

like image 366
gkrogers Avatar asked Feb 02 '10 14:02

gkrogers


People also ask

What does Response redirect method do?

Response. Redirect sends an HTTP request to the browser, then the browser sends that request to the web server, then the web server delivers a response to the web browser. For example, suppose you are on the web page "UserRegister. aspx" page and it has a button that redirects you to the "UserDetail.

What can I use instead of a response redirect?

For instance, instead of a "form" button that causes a postback and redirect, you could use a LinkButton that will behave like a hyperlink, allowing the browser to request the new page directly.

Does response redirect stop execution?

When you use Response. Redirect("Default. aspx",true ) which is by default true then the execution of current page is terminated and code written after the Response. Redirect is not executed instead of executing code written after the Response.


1 Answers

Just for future reference another reason this can occur is if you do something like Response.Redirect(null) or similar. I had a situation where my variable holding the URL was null and this is what I got.

like image 185
Dan Diplo Avatar answered Sep 22 '22 12:09

Dan Diplo