Response.Redirect causes System.Threading.ThreadAbortException
Posted
by RandomBen
on Stack Overflow
See other posts from Stack Overflow
or by RandomBen
Published on 2010-05-05T22:02:43Z
Indexed on
2010/05/05
22:08 UTC
Read the original article
Hit count: 180
When I use Response.Redirect(...) to redirect my form to a new page I get the error:
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code
My understanding of this is that the error is being caused by the webserver aborting the remainder of the page the response.redirect was called on.
I know I can add a second parameter to Response.Redirect that is called endResponse. If I set endResponse to True I still get the error but if I set it to False then I do not. I am pretty sure though that that means the webserver is running the rest of the page I redirected away from. Which would seem to be inefficient to say the least. Is there a better way to do this? Something other than Response.Redirect or is there a way to force the old page to stop loading where I will not get a ThreadAbortException?
© Stack Overflow or respective owner