The first "mscorlib. dll" exception that occurs occasionally in system. Threading. threadabortexception

Source: Internet
Author: User
Tags mscorlib

1. symptom:

When debugging the ASP. NET program, you can view the Visual Studio output window while viewing the browser window. The following information is displayed:

The first "mscorlib. dll" exception that occurs occasionally in system. Threading. threadabortexception
An exception of the "system. Threading. threadabortexception" type occurs in mscorlib. dll, but not in user code.

Internet query: http://www.cnblogs.com/wbcms/archive/2008/03/24/1119307.html

 

2. cause:
Because your code is called internallyResponse. End ()OrResponse. Redirect ("")AndServer. Transfer ("")The two methods, because the two methods also call response. End () internally ().

The response. End method stops page execution and converts the execution to the application_endrequest event in the event pipeline of the application. The code lines after response. End are not executed.

This phenomenon is caused by design.

 

3. solution:

(1), response. End ()->Applicationinstance. completerequestTo skip the code execution of the application_endrequest event.Httpcontext. Current. applicationinstance. completerequest ();

(2), response. Redirect ()->Response. Redirect (string URL, bool endresponse = false),
It passes false to the endresponse parameter to cancel the internal call to response. End. If this solution is used,The Code following response. Redirect will be executed..

(3), server. Transfer ()->Server. Execute ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.