Search code examples
asp.netmultithreadingexception

Why is my ASP.NET application throwing a ThreadAbortException?


Why does this thing bubble into my try-catches even when nothing is wrong?

Why is it showing up in my log, hundreds of times?


Solution

  • This is probably coming from a Response.Redirect call. Check the page ASP.NET - ThreadAbortException for an explanation:

    Just a quick note after some discussion we had at a local user group meeting tonight with regards the ThreadAbortException you sometimes see when working with ASP.NET after making a Response.Redirect, Server.Transfer or Response.End call. Had a quick look with Reflector and on MSDN.

    Calls to Response.Redirect and Server.Transfer all make calls to Response.End internally which raises a ThreadAbortException when the current response ends and execution switches to the Application_EndRequest event. The behavior is by design.

    To prevent the call to Response.End use the Response.Redirect overload with the endResponse parameter set to false.

    (In most cases, calling Response.Redirect(url, false) fixes the problem)