I am developing a web app with an ASP server side and I use an iframe for data push.
An ASP handler flushes every once in a while some javascript to the iframe:
context.Response.Write("<script language='javascript'>top.update('lala');</script>");
context.Response.Flush();
My problem is that sometimes, when I receive the data, I don't get the full text.
For example I will receive this : <script language='javascript'>update('lala');</
Unfortunately this prevents the javascript code from being executed if no other data is to come during the next second or so.
One workaround I have is to have a thread flushing '..........' every 500ms. (Then I will receive script>......
which will complete my javascript.)
However I am sure there must be a way to have Response.Flush() sending the whole chunk of data. Does someone have an idea on how to use properly Response.Flush() ?
Thank you!
Charles
One of my coworkers figured out the problem. Gzip compression was enabled on IIS, which was preventing the web browsers getting full chunks of data.
Among the solutions:
Disable compression for all websites:
For IIS 5.1, go to Control Panel/Administrative Tools/Internet Information Services
. Right click on Web Sites
, click on properties
and remove the ISAPI filter Compression
.
For IIS 7, go to My Documents/IISExpress/config/applicationHost.config
and change the part httpCompression
so that compression is not enabled for your particular page.
Disable compression just for your website:
In the web.config
file of your application, add the line <urlCompression doStaticCompression="true" doDynamicCompression="false"/>
under the section <system.webServer>
.
Disable compression for a particular web page or a particular request
These good guys found a way to do it:
Can gzip compression be selectively disabled in ASP.NET/IIS 7?
If you use gzip compression ratio up to 3, IIS serves chunked page. And there is no significant difference between gzip ratio 3 and 9. Look at IIS compression ratio test
来源:https://stackoverflow.com/questions/11024580/asp-response-flush-flushes-partial-data