Thursday, May 22, 2008
Exception thrown on calling Response.Redirect
Calling Response.Redirect in a Try-Catch block throws a ThreadAbortException. This is by design - a Response.Redirect internally calls Response.End and this throws a ThreadAbortException. You can create a catch handler that catches only the ThreadAbortException, but catching an exception each time would cause a performance overhead. An alternative would be to call the Response.Redirect overload that accepts a boolean value as a second parameter - pass a false to prevent throwing of the ThreadAbortException.