What are the advantage and disadvantage for each of Response.End()
and CompleteRequest()
? Where should I and should I not use them? I looked at this question but I didn't get a proper answer.
CompleteRequest Instead of Response. End.
The End method causes the Web server to stop processing the script and return the current result. The remaining contents of the file are not processed.
Sends all currently buffered output to the client, stops execution of the page, and raises the EndRequest event. public: void End(); C# Copy.
HttpResponse.End
flushes the output buffer to the client and terminates the current request-handling thread (this is bad), whereas HttpApplication.CompleteRequest
tells ASP.NET to immediately skip all future stages in the ASP.NET pipeline and jump directly to the EndRequest step (which also raises the HttpApplication.EndRequest
event). The request thread then proceeds with normal end-of-life cleanup.
So, Response.End
is like an ejector seat: it quickly ends things, but means you lose control and might be unnecessarily harsh. Whereas CompleteRequest
is like making an emergency landing at the nearest airport.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With