NoteWaiting for the server to finish processing all server-side script may cause a lengthy delay. To send pieces of the response to the user before processing is complete, use the Flush method of the Response object throughout your code.
Before you continue with the lesson, run the Chap10b.exe animation located on the CD-ROM that accompanies this book. This animation explains how IIS uses buffering when creating a response to a client.
Example
This example sets the Buffer property to true:Response.Buffer = True
If an error occurs during processing, use the Redirect method of the Response object, with buffering enabled. First, clear the buffer with the Clear method, and then use the Redirect method.
Example
This example clears the buffer and redirects the user to an error page after an error occurs:Response.Buffer = True On Error Resume Next 'code that may cause an unrecoverable error, 'such as failing to open a data connection If Err.number <> 0 Then Response.Clear Response.Redirect "error.htm" End If
The Write method adds text to an HTTP request, and the Redirect method jumps to a different URL. Use the Buffer property to prevent the Web server from sending the HTTP response to the user until all server-side script on the current ASP has been processed.