ASP Response.Flush() flushes partial data

安稳与你 提交于 2019-12-22 09:46:48

问题


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


回答1:


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?




回答2:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!