内容 - 处置标题被发送两次...一次由代码发送另一个未知

[英]content-disposition header being sent twice…once by code the other unknown


I have an .aspx page where I'm manually setting headers to force a download of a pdf file. It works fine in IE, but in chrome and firefox 8.0, it's giving an error.

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

I finally tracked down the source of the problem to the content-disposition header being sent twice but I have no idea how or why it's being set the first time.

我最终将问题的来源追溯到两次发送的内容处置标题,但我不知道它是如何或为什么第一次被设置。

The first instance of the header is just: Content-disposition: Attachment The second is: Content-Disposition:attachment; filename=download.pdf <-- this one set by code

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

is IIS taking over somehow and adding this first instance of the header? If so, how can I toggle it to NOT do that?

IIS以某种方式接管并添加头的第一个实例?如果是这样,我怎么能把它切换到不那样做?

EDIT: adding the code that sets the headers

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

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

1 个解决方案

#1


1  

Check in IIS the HTTP Headers section for that page. Make sure it's not set there.

在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

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2011/11/15/7dd9286c2a4415763ff14a0b514ad495.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告