ASP Response Object : End Method

The End method causes the web server to stop processing the script and return the current result. The remainder of the ASP file is not processed. If Response.Buffer is set to True1, calling the End method will flush the buffer. This will send all of the output that was processed before the call of the End method to the end user.


  Response.Buffer = True
  Response.Write = "Hello<br>"
  Response.Write = "World!"
In this example, "Hello" and a "<br>" tag would be sent to the client's browser, but "World!" would not. The second Response.Write is not even processed by the ASP interpreter since it comes after the call to the End method.

Tips & Hints

Ending Performance Woes
The End method should be used to cancel the processing of scripts to which a user is no longer connected. When a user requests an ASP file, that request is placed in a queue which the ASP engine processes one at a time. If your server is heavily loaded, then this queue can become quite long, meaning that new requests (placed at the end of the queue) may have to wait to be processed for a long time. If the end user gets tired of waiting, they may hit the refresh button, the stop button, or go to another page. In each of these cases, they leave a request in the queue which no longer has a valid connection to a user.

These cases should be detected by your script (using the Response.IsClientConnected property) and removed from the queue before processing. This can be accomplished by a simple If ... Then statement at the beginning of each script.

Example (in VBScript):

  Response.Buffer = True
  If NOT Response.IsClientConnected Then
  End If

  'Rest of your code.

In this example, if the client is not connected, then the End method is called to cancel the processing of this script. In this way, you only waste time processing four lines of code instead of the entire file. On high-traffic servers, this should be required at the beginning of each ASP file.

Back to the ASP Response Object
Back to ASP Objects
1 In IIS 5.0, buffering is True by default.


All code is my own (and still regrets its involvement with Manson to this very day).

Log in or register to write something here or to contact authors.