System.Web.HttpResponse.End Method

Sends all currently buffered output to the client, stops execution of the page, and raises the HttpApplication.EndRequest event.


public void End ()


This method is provided only for compatibility with ASP—that is, for compatibility with COM-based Web-programming technology that preceded ASP.NET. If you want to jump ahead to the HttpApplication.EndRequest event and send a response to the client, it is usually preferable to call HttpApplication.CompleteRequest instead.

To mimic the behavior of the End method in ASP, this method tries to raise a . exception. If this attempt is successful, the calling thread will be aborted, which is detrimental to your site's performance. In that case, no code after the call to the HttpResponse.End method is executed.

If the HttpResponse.End method is not able to raise a ., it instead flushes the response bytes to the client. It does this synchronously, which can also be detrimental to your site's performance.

In either case (whether or not a . exception is successfully raised), the response pipeline jumps ahead to the HttpApplication.EndRequest event.

The HttpApplication.CompleteRequest method does not raise an exception, and code after the call to the HttpApplication.CompleteRequest method might be executed. If your intention is to avoid execution of subsequent code, and if the performance penalty of HttpResponse.End is acceptable, you can call HttpResponse.End instead of HttpApplication.CompleteRequest.


Namespace: System.Web
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0,