我有一个简单的网站有两页。其中显示文件列表,当它被点击列表中的其他流的文件。所有在生产的6个月罚款,但现在我必须到现场迁移到Windows 2008 / IIS7。我有它大多工作,但因为我的Content-Type头被忽略的文件不进行适当放开(在Firefox)。对生产现场(IIS6)的报头(使用招):

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和一直在努力找到在哪里更改各种设置。我还是设法弄清楚有关这两个托管管道模式,并通过切换到经典.net应用程序池修复了一些其他问题(集成在传输文件时,抛出各种错误)。

是否有某种方式来告诉IIS7不覆盖我的内容类型标头,如果这是发生了什么事?

有帮助吗?

解决方案

您有没有修改的HttpModules请求/响应?是web.config文件中完全一样?

在哪里这些额外的2K字节来自哪里?在其中有什么?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top