我有一个有两页的简单网站。一个显示文件列表,另一个文件在列表中单击时流式传输。生产6个月都很好,但现在我必须将网站移动到Windows 2008 / IIS7。我有它主要工作,但文件无法正常打开(在Firefox中)因为我的内容类型标题被忽略。在生产站点(IIS6)上,标题是(使用Fiddler):
HTTP/1.1 200 OK
Date: Tue, 09 Feb 2010 16:00:51 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Content-Disposition: attachment; filename="myfile__foo.pdf"
Content-Length: 236841
Cache-Control: no-cache, no-store
Pragma: no-cache
Expires: -1
Content-Type: application/octet-stream
但是在我测试的IIS7服务器上:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 236841
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
Content-Disposition: attachment; filename="myfile__foo.pdf"
Fiddler还报告违反协议并说“内容长度不匹配:响应标头声称236841字节,但服务器发送了238378字节。”
我的代码如下所示:
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + doc.DisplayFilename + "." + doc.FileExtension + "\"");
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.TransmitFile(file.FullName);
Response.End();
我一直试图解决这个问题几天。我对IIS7并不熟悉,并且很难找到改变各种设置的位置。我确实设法弄清楚了两种管理流水线模式,并通过切换到Classic .NET AppPool修复了一些其他问题(Integrated在传输文件时抛出了各种错误)。
有没有办法告诉IIS7不要覆盖我的ContentType标头,如果发生了什么?
答案 0 :(得分:0)
您没有修改请求/响应的HttpModules吗? web.config文件是否完全相同?
这些额外的2K字节来自哪里?它们里面有什么?