Response.Redirect exception

Posted by Tedd Hansen on Stack Overflow See other posts from Stack Overflow or by Tedd Hansen
Published on 2011-01-04T11:11:00Z Indexed on 2011/01/04 12:54 UTC
Read the original article Hit count: 192

Filed under:

Executing the line:

Response.Redirect("Whateva.aspx", true);

Results in:

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

The exception is because of the "true" part, telling it to end the current request immediately.

Is this how it should be?
If we consider:

  • Exceptions are generally considered heavy, and many times the reason for ending the request early is to avoid processing the rest of the page.
  • Exceptions show up in performance monitoring, so monitoring the solution will show a false number of exceptions.

Is there an alternative way to achieve the same?

© Stack Overflow or respective owner

Related posts about ASP.NET