Thread was being aborted

淺唱寂寞╮ 提交于 2019-11-29 09:03:46

This exception is throw by the call to Server.Transfer in order to halt the execution of the current method - exactly the same thing gets thrown if you do Response.Redirect.

The two choices you have are:

  • Catch and rethrow the ThreadAbortException / reperform the Server.Transfer
  • Make sure that you only do Server.Transfer in places where it wont be caught (recommended)

EDIT: Scratch that, http://support.microsoft.com/kb/312629 has a couple of other suggestions to try, but I still recommend #2 above.

Another way to solve this, is to catch the generated error and to not rethrow it:

        catch (ThreadAbortException)
        { 
        }
Matt Wrock

Caling Server.Transfer will call Response.End which always throws a ThreadAbortException. This is a "special" exception because while it can be caught in a catch block, it will always be re thrown at the end of the catch block. I would have your error logging ignore ThreadAbortExceptions.

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

Solution for this Problem is as follows.

For Server.Transfer, use the Server.Execute method instead.

Visit this link for download sample example. http://jayeshsorathia.blogspot.com/2012/03/thread-was-being-aborted-error-occured.html

user6706374

Replacing Response.End() by the following helped fix the problem.

Response.Flush(); Response.Close();

Refer Can we use Response.Flush () instead of Response.End()

Zuhair Ali

Replace Response.End() With HttpContext.Current.ApplicationInstance.CompleteRequest();

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!