1

我正在使用此标头将文件附加到 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 站点。请求的站点不可用或找不到。请稍后再试。

4

3 回答 3

3

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

Response.ContentType = "application/vnd.ms-word"
Response.AddHeader "Cache-Control", "max-age=0" 
于 2011-02-18T18:55:48.650 回答
2

也许试试这个解决方法?

<iframe src="page.html?var=xxx" id="theframe"></iframe>

<script>
var _theframe = document.getElementById("theframe");
_theframe.contentWindow.location.href = _theframe.src;
</script>
于 2011-02-21T14:04:21.367 回答
1

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

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

于 2011-02-21T12:53:33.793 回答