exception – Why am I getting Thread was being aborted in ASP.NET?

exception – Why am I getting Thread was being aborted in ASP.NET?

Nope, ThreadAbortException is thrown by a simple Response.Redirect

ASP.NET spawns and kills worker processes all the time as needed. Your thread may just be getting shut down by ASP.NET.

Old Answer:

Known issue: PRB: ThreadAbortException Occurs If You Use Response.End, Response.Redirect, or Server.Transfer

Response.Redirect (bla.aspx, false);

or

try
{
    Response.Redirect(bla.aspx);
}
catch (ThreadAbortException ex)
{
}

exception – Why am I getting Thread was being aborted in ASP.NET?

If you spawn threads in Application_Start, they will still be executing in the application pools AppDomain.

If an application is idle for some time (meaning that no requests are coming in), or certain other conditions are met, ASP.NET will recycle the entire AppDomain.

When that happens, any threads that you started from that AppDomain, including those from Application_Start, will be aborted.

Lots more on application pools and recycling in this question: What exactly is Appdomain recycling

If you are trying to run a long-running process within IIS/ASP.NET, the short answer is usually Dont. Thats what Windows Services are for.

Leave a Reply

Your email address will not be published.