Response.redirect raises "Thread was being aborted"
Solution 1:
By default, Response.Redirect()
aborts the current thread. Naturally, this throws a ThreadAbortException
. It can be prevented by passing a false
to Response.Redirect()
, which won't abort the current thread.
Be aware of what that means, however. If the thread is not aborted, the code following the Response.Redirect()
will continue to execute. Control your logic flow accordingly. (This is often done with return
statements and other flow control directives following a redirect.)
Solution 2:
Response.Redirect
will always throw a ThreadAbortException
, according to MSDN documentation if you don't give a false
boolean value to endResponse
input parameter HttpRequest.Redirect(string, bool)
.
Just give false
to endResponse
parameter.
Solution 3:
The list of options for solving this issue laid out here worked for me (I used #2): https://gist.github.com/cemerson/9dea993044a4e7fdca0e