Why am I getting "Thread was being aborted" in ASP.NET?
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){}
If you spawn threads in Application_Start
, they will still be executing in the application pool's 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 "Don't". That's what Windows Services are for.