Response.Flush() only works with Firefox Response.Flush() only works with Firefox google-chrome google-chrome

Response.Flush() only works with Firefox


Also, be aware that if your IIS server is compressing the output with GZIP, then it will seem to ignore all Response.Flush calls.

This is turned on by default in IIS7 and on Windows 7.

And, if you are testing with Fiddler, be sure to turn on "Streaming" mode, or Fiddler will collect the flushed HTML and hold it until the connection is completed.


The problem you are facing is that the response you are sending is still incomplete. Even though you flush whatever is in the buffers to the browser, it is still up to the browser to wait for the response end or process what it's got so far - hence the difference between browsers.

What's even worse is that you can expect the same behavior from some intermediate nodes concentrators, firewalls, etc. located on the internet between your server and the browser.

The bottom line is that if you want to ensure that browser does something with your data stream you have to complete it with Response.End.

In other words if you want to send some of your response data first and delay sending the rest your better option is to break the response in two, complete the first one and download the second part separately


An easy way to resolve this is to place a "Please wait, processing" page in front of the actual page that does the work. The "please wait" message is displayed and then it immediately starts processing by using a meta refresh tag and/or javascript to redirect to the actual processing page.

"Please Wait" Page:

<html><head>  <meta http-equiv="refresh" content="0;url=process.aspx?option1=value&...." />  <title>Please Wait, Processing</title></head><body>  Processing...</body><script type="text/javascript">  window.location = "process.aspx?option1=value&....";</script></html>

Notes:

  1. Using two methods to kick off the processing is done to ensure if a browser can't use one, it will hopefully use the other method.
  2. You will have to replace the processing url and querystring to suit.
  3. One downside of this method is that if the user hits the browser back button, they will be going back to the "please wait" page from the "process" page, meaning it will accidentally kick off the job again. I'll leave that challenge for another topic!