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