日期:2014-05-17  浏览次数:20514 次

iis启用gzip压缩后 不能下载文件
iis设置了gzip压缩。照成respose.write输出时候filename后面多加了.gzip后缀!该情况只在ie6下出现!
谢谢

------解决方案--------------------
IIS在启用gzip压缩后,在服务器端生成的Excel2007文件,下载后文件打不开了。

Excel2007文件实际上是一个压缩包,下载后右键查看文件属性,摘要选项卡不正常,怀疑文件格式在下载的过程中被改变了,不知道是在哪个环节上出了问题。

以下是下载的代码:

response.Clear();
response.ClearHeaders();
response.ClearContent();
response.Buffer = false;
response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
response.ContentEncoding = Encoding.UTF8;
response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileInfo.Name, Encoding.UTF8));
response.AppendHeader("Content-Length", fileInfo.Length.ToString());
response.WriteFile(fileInfo.FullName);
response.Flush();
response.End();

有试过在HTTP 头中指明gzip,问题还是存在 现在已经不用IIS压缩了,改使用HttpModule方式,配合自定义过滤机制,实现压缩 

或参考:
http://www.cnblogs.com/ppchen/archive/2009/02/19/1382530.html