1

我有一个 .aspx 页面,我在其中手动设置标题以强制下载 pdf 文件。它在 IE 中运行良好,但在 chrome 和 firefox 8.0 中,它给出了一个错误。

我终于找到了问题的根源,因为 content-disposition 标头被发送了两次,但我不知道第一次是如何设置或为什么设置它的。

头的第一个实例就是:Content-disposition:Attachment 第二个是:Content-Disposition:attachment; filename=download.pdf <-- 这个由代码设置

IIS 是否以某种方式接管并添加标头的第一个实例?如果是这样,我怎样才能将其切换为不这样做?

编辑:添加设置标题的代码

Response.ContentType = "application/pdf";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
                Response.WriteFile(fname);
                Response.Flush();
                Response.End();
4

1 回答 1

1

在 IIS 中检查该页面的 HTTP 标头部分。确保它没有在那里设置。

IIS6:http ://weblogs.asp.net/joelvarty/archive/2009/03/23/force-ie7-compatibility-mode-in-ie8-with-iis-settings.aspx

IIS7:http ://technet.microsoft.com/en-us/library/cc753133(WS.10).aspx

于 2011-11-15T18:26:59.763 回答