Why not use Response. Close () and response. close

Source: Internet
Author: User

Why not use Response. Close () and response. close

 

Do not use Response. Close ()

Do not use Response. Close ()

Do not use Response. Close ()

1 because: the Close () method will call the HttpWorkerRequest. CloseConnection () method. Terminate (Terminate) the socket connection with the client, and invalidate the cache (buffer) on the server, client, and inter-facility. Data sent to the client is lost.

2The Response. End () method is introduced in ASP. NET 1.0 to be compatible with classical Asp programs. A ThreadAbortException exception is thrown after the call. When the call succeeds, the current (abort) thread is aborted to process the EndRequest event triggered by the MPs queue, and subsequent code is not processed. The response content is sent to the client in synchronous mode (flush.

Due to the design of. NET, Response. End () can terminate code execution in the WebForm framework and no longer process code after End. In the MVC framework, only the response stream is returned and code execution is not aborted.

3You can also use HttpApplication. CompleteRequest () to end the request.

Response. Flush ();

This. Context. ApplicationInstance. CompleteRequest ();

To sum up, you can use Response. Close () only when the code is wrong (malicious attack) and you want to terminate the Response/connection to the client ()

If you want to end the request and send the request to the client, the HttpApplication. CompleteRequest () method should be used first.

References:

1 http://weblogs.asp.net/hajan/why-not-to-use-httpresponse-close-and-httpresponse-end

2 http://stackoverflow.com/questions/1886729/httpresponse-end-vs-httpresponse-close-vs-httpresponse-suppresscontent

3 http://www.cnblogs.com/v5wa/p/3165367.html

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.