
380
|
Chapter 17: The HttpResponse Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Example
The example below writes the text “Hello, World!” to the browser, calls Response.
End, and then attempts to set the Text property of the Message ASP.NET Label
control to “Hello, World!” However, that code will not be executed, as the End
method immediately halts execution of page processing.
Sub Page_Load( )
Response.Write("Hello, World!")
Response.End( )
Message.Text = "Hello, World!"
End Sub
In fact, the code above will result in only the “Hello, World!” text being output to
the browser, as even the rendering of the static HTML and controls in the page
will not occur.
Notes
When the End method is called, in addition to sending buffered output to the
client and terminating processing, the Application_EndRequest event is fired.
Flush
Response.Flush( )
Immediately sends all buffered output to the client.
Parameters
None
Example
See the example for the BufferOutput property. If you comment out the lines that
set BufferOutput to
False and then uncomment the line that calls Response.Flush,
you will see that the Flush method allows you to explicitly send buffered content
to the browser.
Notes
Since buffering is on by default in ASP.NET, the Flush method becomes espe-
cially useful. Rather than turning off buffering, which results in any content sent
from ...