Response.Flush object to send outputs

When response buffering is enabled, Classic ASP can hold generated output until the page completes. Response.Flush sends the output currently in that buffer while allowing the script to continue. This can be useful when a long-running page needs to send partial progress information.

Response.Flush requires buffering to be enabled. Current IIS Classic ASP configuration uses buffering by default, although administrators can change it.

Response object error 'ASP 0159 : 80004005' 
Buffering Off
/a/response/flush.asp, line 15
Buffering must be on.
You can read more on ASP buffer here. In current IIS Classic ASP configuration, buffering is enabled by default. Now let us try with some examples to show how Response.Flush works.
<%@ Language=VBScript %>
<% Option Explicit 
Response.Buffer = True

%>

<html><head>
<title>(Type a title for your page here)</title>
</head>
<body >

<%
Dim i
Response.Write("Message No 1 : Before  Flush <br>")
Response.Flush
Response.Write("Message No 2 : After Flush <br>")
%>
You will get two lines of out put ( Message No 1 & Message No 2 ) , you will not able to experience the difference between Message No 1 & 2 as the code is very small and it will be executed fast. Now we will introduce some delay by using a for loop so you can see the time gap between two line of messages. You may have to adjust the delay time by changing the upper value depending on your system. Here is the code.
<%
Dim i
Response.Write("Message No 1 : Before  Flush <br>")
Response.Flush
For i=1 to 100000000
Next
Response.Write("Message No 2 : After Flush <br>")
%>
You will get the first Message ( No 1 ) as response.Flush will send the output from buffer to client machine. Then after the time delay ( because of for loop ) you will get the second message line. Try the same script again by removing ( or commenting ) the Response.Flush line.

Note: The large For loop is only a simple timing demonstration. Do not use CPU-burning loops to create delays in production applications.

You will see both the lines of message after the time delay when script execution is over.

The difference between Response.Flush and Response.Clear is in former case the data is posted to client machine and then removed from buffer, in later case data is removed from buffer without sending to client browser.
ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer