IE 无法通过 WebSphere 提供的 SSL 下载文件
IE 7 和当用户尝试通过 https 下载 csv 文件时,8.0.8 都会抛出错误。
Internet Explorer 无法下载 downloadPage.jsf。 Internet Explorer 无法打开该网站。请求的站点不可用或无法找到。请重试
我读到了 IE 与缓存相关的问题,因此我更改了响应以允许公共缓存。请参阅此问题: IE 无法下载 foo.jsf。 IE 无法打开该网站。请求的站点不可用或找不到
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "public");
但我仍然收到此错误。
您知道还有什么可能导致该问题吗?这是完整的片段:
HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
response.setContentType("text/plain");
response.setHeader("Content-Disposition", "attachment; filename=\"" + browserFilename + "\"");
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "public");
response.getOutputStream().write(contentBytes);
context.responseComplete();
IE 7 & 8 both throw an error when users attempt to download a csv file over https.
Internet Explorer cannot download downloadPage.jsf. Internet Explorer was not able to open this internet site. The requested site is either unavailable or cannot be found. Please try again
I read about the issues IE has in relation to caching so I changed the response to allow public caching. See this issue: IE cannot download foo.jsf. IE was not able to open this internet site. The requested site is either unavailable or cannot be found
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "public");
But I am still getting this error.
Any ideas what else could be causing the issue? Here's the complete snippet:
HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
response.setContentType("text/plain");
response.setHeader("Content-Disposition", "attachment; filename=\"" + browserFilename + "\"");
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "public");
response.getOutputStream().write(contentBytes);
context.responseComplete();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
当响应中包含 cookie 时,WebSphere 似乎会自动添加 Cache-Control:no-cache=set-cookie 响应标头。 IE8&较老的人在通过 SSL 下载时不喜欢这样。
根据此 IBM Developerworks 论坛帖子,有两个可能的修复方法:
为WebSphere 中的HTTP 传输通道添加自定义响应标头
CookiesConfigureNoCache:false
(默认情况下为true)。添加 cookie 之后显式设置
Cache-Control
标头,这将覆盖 WebSphere 设置的标头。It appears that WebSphere automatically adds
Cache-Control:no-cache=set-cookie
response header when cookies are included in the response. IE8 & older do not like this when downloading over SSL.There are two possible fixes as per this IBM Developerworks forum thread:
Add the custom response header
CookiesConfigureNoCache:false
for HTTP transport Channel in WebSphere (it's true by default).Explicitly set the
Cache-Control
header after cookies are being added, this will override the WebSphere-set one.我用IE8也遇到同样的问题。
我对我的代码做了一些小改动。
Response.ClearHeaders(); //需要,否则“no-cache: set-cookie”就在那里,必须删除它
Response.addHeader("Cache-Control", "private");
I had the same issue with IE8.
I made small changes to my code.
Response.ClearHeaders(); //needed, otherwise "no-cache: set-cookie" was there, had to get rid of it
Response.addHeader("Cache-Control", "private");
当应用程序服务器配置为使用 SSL 时,存在完全相同的问题。我在启用 https 后使其正常工作的技巧:
Had the exact same issue when the app server was configured to use SSL. The trick for me to get it working after the https was turned on:
我认为您在缓存方面走在正确的道路上:
这篇知识库文章可能会帮助您,
Internet Explorer 无法从 SSL 网站打开 Office 文档
此 Stack Overflow 问题中提到: 无法在 IE 中打开 xls 文件
I think you are on the right track with caching:
This knowledge base article may help you,
Internet Explorer is unable to open Office documents from an SSL Web site
Mentioned in this Stack Overflow question: Cannot open xls file in IE
我也遇到了同样的问题。
设置“Content-Disposition”和“Content-Type”后,添加此代码。
Java代码
PHP代码
I hade the same problem.
After set "Content-Disposition" and "Content-Type", add this code.
Java code
PHP code
这是我在 PHP 代码中所做的事情:
Here's what I've done in my PHP code: