HttpResponse.End HttpResponse.End HttpResponse.End HttpResponse.End Method

定義

將目前所有受緩衝的輸出傳送到用戶端、停止網頁的執行,並引發 EndRequest 事件。Sends all currently buffered output to the client, stops execution of the page, and raises the EndRequest event.

public:
 void End();
public void End ();
member this.End : unit -> unit
Public Sub End ()

例外狀況

End() 呼叫已終止目前要求。The call to End() has terminated the current request.

備註

提供這個方法是只為了與 ASP-相容性也就是使用以 COM 為基礎的 Web 程式設計技術的 ASP.NET 相容性。This method is provided only for compatibility with ASP - that is, for compatibility with COM-based Web-programming technology that preceded ASP.NET. 如果您想要往前跳至EndRequest事件和傳送回應給用戶端,它通常最好是呼叫CompleteRequest改。If you want to jump ahead to the EndRequest event and send a response to the client, it is usually preferable to call CompleteRequest instead.

若要模擬的行為EndASP 中的方法,這個方法會嘗試以引發ThreadAbortException例外狀況。To mimic the behavior of the End method in ASP, this method tries to raise a ThreadAbortException exception. 如果此嘗試成功,呼叫的執行緒將會中止,也就是危害到您的網站效能。If this attempt is successful, the calling thread will be aborted, which is detrimental to your site's performance. 在此情況下,在呼叫之後任何程式碼End執行方法。In that case, no code after the call to the End method is executed.

如果End方法不是引發ThreadAbortException,它改為排清回應位元組至用戶端。If the End method is not able to raise a ThreadAbortException, it instead flushes the response bytes to the client. 它會以同步方式,可能也會危害到您的網站效能。It does this synchronously, which can also be detrimental to your site's performance.

在任一情況下 (是否ThreadAbortException成功引發例外狀況),回應管線直接跳到EndRequest事件。In either case (whether or not a ThreadAbortException exception is successfully raised), the response pipeline jumps ahead to the EndRequest event.

CompleteRequest方法不會引發例外狀況,和呼叫後的程式碼CompleteRequest方法可能會執行。The CompleteRequest method does not raise an exception, and code after the call to the CompleteRequest method might be executed. 如果您的用意是為了避免執行後續的程式碼,而且會降低效能End是可接受的您可以呼叫End而不是CompleteRequestIf your intention is to avoid execution of subsequent code, and if the performance penalty of End is acceptable, you can call End instead of CompleteRequest.

適用於