0

I have configured my asp .net website in local IIS , if i made any changes in app_Code file then web site is compiled and some time "Thread is being aborted" error is raised . I can't find reason or reproduce the issue.. Give some suggestions..

bgs
  • 3,061
  • 7
  • 40
  • 58
  • 1
    You should check this answer http://stackoverflow.com/a/4874947/407183 it is a very common issue for a asp.net site using Response.Redirect. Response.Redirect will aborts the current thread in default. – ValidfroM Jun 14 '13 at 12:08
  • possible duplicate of [Response.redirect raises "Thread was being aborted"](http://stackoverflow.com/questions/4874823/response-redirect-raises-thread-was-being-aborted) – undefined Jun 15 '13 at 09:59

1 Answers1

6

In the cases I have run across this it typically has to do with the use of Response.Redirect, Server.Transfer, or Response.End being called before all of the code in a given method has had a chance to run. Take this example:

 try
 {
   //Call database method
 }
 catch(Exception ex)
 {
    Response.Redirect("error.aspx");
 }
 finally
 {
    Response.Redirect("success.aspx");
 }

 textbox1.Text = "complete!"; //Never called - Thread is being aborted exception

In the case that the database call throws an error a redirect to error.aspx takes place otherwise a redirect to success.aspx is raised which means the call to textbox1.Text is never executed and thus the error.

Here is the relevant KB article

--Edit

If you are unsure where this problem is being thrown from I would suggest handling the Application_Error event in your Globabl.asax and logging the information. Additionally you could look at the EventViewer on the server and see if the exception is being logged there. If it is it should at least have the stack trace. An example of handling the Application_Error event:

void Application_Error(object sender, EventArgs e)
{
    var context = ((HttpApplication)sender).Context;   
    var ex = context.Server.GetLastError();
    //Log exception
}   
dparsons
  • 2,812
  • 5
  • 28
  • 44
  • Hai , Unable to got exact solution using your sample , because i have used more then 1000 pages in my project , so i can't cauught exact palce issue raised. But this hint is useful. Anyway thanks... – bgs Jun 14 '13 at 11:33
  • I have edited my post to indicate how you might go about tracking the problem down. – dparsons Jun 14 '13 at 11:40