【问题标题】:Internet Explorer ignores Content-Disposition over HTTPSInternet Explorer 忽略 HTTPS 上的 Content-Disposition
【发布时间】:2011-06-29 01:16:26
【问题描述】:

我正在使用此标头将文件附加到 http 响应:

Content-Disposition: attachment; filename="example.doc"

除非我尝试使用 Internet Explorer 通过 HTTPS 下载文件,否则它可以完美运行。 IE 忽略 Content-Disposition 标头,只是尝试下载服务器端脚本文件(经典 ASP)并失败。

我尝试了各种不同的标头(主要与缓存相关),但都没有成功。

如何让 IE 识别附件?

编辑:通过设置 iframe 的 src 属性发送下载请求。不使用 iframe 时,下载工作完美。

编辑 2: 当下载确认对话框出现时,我可以点击打开在 IE 中打开文件,但保存文件不起作用。错误:

无法从 server.com 下载 download.asp。

无法打开此 Internet 站点。请求的站点不可用或找不到。请稍后再试。

【问题讨论】:

    标签: internet-explorer asp-classic https download content-disposition


    【解决方案1】:

    你在设置 ContentType 吗?也尝试设置 Cache-Control。

    Response.ContentType = "application/vnd.ms-word"
    Response.AddHeader "Cache-Control", "max-age=0" 
    

    【讨论】:

    • 谢谢阿米特/乔尔。当不使用 iframe.src 下载文件时,这确实有效。不过,我在使用 iframe 时仍然遇到问题。
    【解决方案2】:

    当 Internet Explorer 通过 SSL 与安全网站通信时,Internet Explorer 会强制执行任何无缓存请求。如果存在一个或多个标头,Internet Explorer 不会缓存该文件。因此,Office 无法打开该文件。

    希望允许此类操作的网站应删除无缓存标头或标头。

    【讨论】:

    • 删除所有无缓存标头后,我仍然收到相同的错误消息。
    【解决方案3】:

    也许试试这个解决方法?

    <iframe src="page.html?var=xxx" id="theframe"></iframe>
    
    <script>
    var _theframe = document.getElementById("theframe");
    _theframe.contentWindow.location.href = _theframe.src;
    </script>
    

    【讨论】:

    • 谢谢先生。设置 contentWindow.location.href 就可以了。
    • 您将在接下来的 24 小时内收到您的赏金。
    • 哇!干杯!很高兴我能帮上忙!
    猜你喜欢
    • 2015-07-08
    • 2011-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-30
    • 2012-09-20
    • 2014-02-22
    相关资源
    最近更新 更多