如何关闭下载的 zip 文件的 HTTP 压缩?
我有一个启用了 HTTP 压缩(通过 IIS 设置)的 ASP.NET Web 应用程序。该应用程序的功能之一是创建多个文本文件并将它们打包为单个 zip 文件以供用户下载。
启用 HTTP 压缩后,应用程序创建的文件将被压缩两次 - 一次由 Web 应用程序压缩,另一次由 HTTP 压缩压缩;结果是,当用户下载 zip 文件时,它有 1 个文件,即应用程序生成的 zip 文件,而第二个 zip 文件具有原始内容。
我的要求是仅对 zip 文件禁用 HTTP 压缩。我该如何实现这一目标?文件扩展名“zip”不包含在用于压缩的配置数据库文件中。
I have an ASP.NET web application that has HTTP compression enabled (through IIS settings). One of the features of the app involves creating multiple text files and packaging them as a single zip file to be downloaded by the user.
With HTTP compression enabled, the files created by the application are zipped twice - once by the web application and once more by HTTP compression; with the result that when the user downloads the zip file, it has 1 file which is the application generated zip file, and this second zip file has the original contents.
My requirement is to disable HTTP compression only for the zip file. How do I achieve this? The file extension "zip" is not included in the metabase file for compression.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没关系,我发现问题是什么:http://support.microsoft.com/kb/841120
虽然本文说的是 Sharepoint,但相同的解决方案也适用于我的情况。我通过将代码中的 MIME 类型更改为“application/octet-stream”而不是“application/x-zip-compressed”来修复此问题(因为我正在动态生成 zip 文件)。这似乎已经解决了。
Never mind, I found what the issue is: http://support.microsoft.com/kb/841120
Though this article says Sharepoint, the same solution is applicable in my case also. I fixed it by changing the MIME type to "application/octet-stream" instead of "application/x-zip-compressed" in my code (since I'm generating the zip file on the fly). That seems to have fixed it.
1.通过在命令提示符处执行以下命令来禁用全局静态压缩:
adsutil set w3svc/filters/compression/parameters/HcDoStaticCompression false
请访问该站点以获取上述详细信息,因为这些详细信息摘自:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/502ef631-3695-4616-b268 -cbe7cf1351ce.mspx?mfr=true
另请参阅 http://blogs.msdn.com/b/carloc/archive/2008/12/31/how-to-disable-http-compression-对于特定文件类型.aspx 。
这可能有帮助
1.Disable global static compression by executing the following command at a command prompt:
adsutil set w3svc/filters/compression/parameters/HcDoStaticCompression false
Look into the site for above mentioned details as these are extracted from:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/502ef631-3695-4616-b268-cbe7cf1351ce.mspx?mfr=true
Also look into http://blogs.msdn.com/b/carloc/archive/2008/12/31/how-to-disable-http-compression-for-specific-file-types.aspx .
This may help