Internet Explorer 忽略 HTTPS 上的内容处置
我使用此标头将文件附加到 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 站点。请求的站点不可用或无法找到。请稍后重试。
I'm attaching a file to an http response using this header:
Content-Disposition: attachment; filename="example.doc"
It works perfectly unless I try to download the file over HTTPS using Internet Explorer.
IE ignores the Content-Disposition header and just tries to download the server-side script file (classic ASP) and fails.
I've tried all kinds of variations of headers (mostly cache-related) with no success at all.
How can I get IE to recognize the attached file?
Edit: The download request is sent by setting the src attribute of an iframe. Downloads work perfectly when not using an iframe.
Edit 2: When the download confirmation dialog appears I can click Open to open the file in IE, but saving the file doesn't work. The error:
Unable to download download.asp from server.com.
Unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您正在设置 ContentType 吗?也尝试设置缓存控制。
Are you setting the ContentType? Try setting the Cache-Control also.
也许尝试这个解决方法?
Maybe try this workaround?
当 Internet Explorer 通过 SSL 与安全网站通信时,Internet Explorer 会强制执行任何无缓存请求。如果存在一个或多个标头,Internet Explorer 不会缓存该文件。因此,Office 无法打开该文件。
想要允许此类操作的网站应删除一个或多个无缓存标头。
When Internet Explorer communicates with a secure Web site through SSL, Internet Explorer enforces any no-cache request. If the header or headers are present, Internet Explorer does not cache the file. Consequently, Office cannot open the file.
Web sites that want to allow this type of operation should remove the no-cache header or headers.