The topic is interrupted

I am getting a "Thread is aborted" Exception on an ASP.NET page. I am not using any Response.Redirect / Server.Transfer method at all. Can anyone help me solve this problem?

+1


source to share


3 answers


This can happen if the web application shuts down or is forced to restart while the code is running. I've seen this when your web application writes files to the web directory it is hosted in, which causes the web application to be recompiled.



+1


source


Bad solution uses

Response.Redirect(URL, False)

      

which will result in the non- current page Response.End (), however this can lead to problems because the rest of the page will executeand can cause login bypass and similar security and performance issues.



Edit: Obviously you are not using Response.Redirect and you cannot catch the AbortThreadExecution with Try Catch, which means that now this answer is completely useless :)

To get an answer, though, you need to learn how to ask a question. you need to provide information such as:

  • Exception details
  • When is it, what are the symptoms
  • What have you tried and didn't work?
  • Are you dealing with isolation issues?
+1


source


Error : The topic was interrupted. at System.Threading.Thread.AbortInternal () at System.Threading.Thread.Abort (Object stateInfo) at System.Web.HttpResponse.End ()

This error occurs mainly if you are using Response.End, Response.Redirect or Server.Transfer

Cause : The Response.End method ends execution of the page and transfers execution to the Application_EndRequest event in the application event pipeline. The line of code that follows Response.End is not executed.

This issue occurs in the Response.Redirect and Server.Transfer methods because both methods call Response.End internally.

Resolution / Decision

You can use try-catch statement to throw this exception

or

For Response.End, call the HttpContext.Current.ApplicationInstance.CompleteRequest method instead of Response.End to bypass code execution in the Application_EndRequest event. For Response.Redirect, use the Response.Redirect (String url, bool endResponse) overload, which passes false for the endResponse parameter to suppress the internal call to Response.End. For example: ex: Response.Redirect ("nextpage.aspx", false); If you use this workaround, the code following Response.Redirect is executed. For Server.Transfer, use the Server.Execute method instead.

0


source







All Articles