无法在 IE8+ 中从 SSL 加密网页下载文件; - 无法修改 ASP.NET 中的标头
我在网页运行方面遇到了困难,确实需要一些帮助。该页面通过启用了 SSL 的 IIS 7 提供服务。在其上,用户可以下载一个 .rtf 文档或多个 .rtf 文件的 .zip。这在 FF 和 Chrome 中工作得很好,但一旦引入 IE,最终用户就会收到一个弹出窗口,并显示以下错误:
无法打开此 Internet 站点。请求的站点不可用 或找不到。请稍后重试。
使用 Fiddler,我可以看到标头的 Cache-Control 设置为 No-cache,并且 Pragma 也设置为 no-cache。根据多个论坛和博客,这会导致 IE 禁止从页面下载文件。
我尝试像这样更改 ASP.NET 代码隐藏中的标头:
Response.AppendHeader("Pragma", "public");
Response.AppendHeader("Cache-Control", "must-revalidate,
post-check=0, pre-check=0");
Response.AppendHeader("Cache-Control", "public");
和这样:
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetMaxAge(TimeSpan.FromMinutes(1));
Response.Cache.SetValidUntilExpires(true);
没有一个有效。标头仍设置为无缓存。
然后,我尝试通过 IIS HTTP 响应标头模块向网站添加自定义标头修改,但这也不起作用。
此主题接近回答我的问题,但没有具体说明他们如何重写标题。
当我拔掉剩下的头发时,我将非常感谢你们能给我的任何帮助。
I am having a terrible time getting a webpage to work and could really some help. The page is served via IIS 7 with SSL enabled. On it, the user can download an .rtf document or a .zip of multiple .rtf files. This works perfectly fine in FF and Chrome, but as soon as IE is introduced, the end user gets a popup with the following error:
Unable to open this Internet site. The requested site is either unavailable
or cannot be found. Please try again later.
Using Fiddler, I can see that the header has Cache-Control set to No-cache and the Pragma is set to no-cache as well. Based on several forums and blogs, this causes IE to disallow downloading of files from the page.
I have tried to change the headers in the ASP.NET codebehind like this:
Response.AppendHeader("Pragma", "public");
Response.AppendHeader("Cache-Control", "must-revalidate,
post-check=0, pre-check=0");
Response.AppendHeader("Cache-Control", "public");
and this:
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetMaxAge(TimeSpan.FromMinutes(1));
Response.Cache.SetValidUntilExpires(true);
none of which works. The headers are still set as no-cache.
I then tried to add custom header modifications to the website via IIS HTTP Response Headers module, but that isn't working either.
This thread comes close to answering my question but doesn't specify how they were able to rewrite the headers.
I will greatly appreciate any help you folks can give me as I am pulling what's left of my hair out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我遇到的同一问题的链接。但我有一个 .pdf 版本。它实际上适用于所有静态文件类型。
IE8 和客户端缓存
Here is a link to the same issue I had. Except I had it with a .pdf. It actually applies to all static file types.
IE8 and client side caching
它已经得到回答,但我想我应该添加另一个对我有帮助的答案。
由于您使用的是 IIS 7,因此您可以使用
来删除 Pragma 标头。 AppendHeader 方法不会覆盖任何预先存在的标头,包括其他 Pragma 标头,因此“Pragma:no-cache”仍然存在。现在,使用 IIS 7,您可以将其删除。
如果您没有 IIS 7,或者您的本地计算机配置为运行 IIS 6,即使您像我的一样有 IIS 7,您也会收到“此操作需要 IIS 集成管道模式”异常。只要确保您运行的是 IIS 7 就可以了。
It's already answered, but I figured I'd add another answer that helped me.
Because you're on IIS 7, you can use
to remove the Pragma header. The AppendHeader method doesn't override any pre-existing headers, including other Pragma headers, so the "Pragma: no-cache" was still present. Now, with IIS 7, you can remove it.
If you don't have IIS 7, or your local machine is configured to run IIS 6, even though you have IIS 7 available like mine was, you'll get a "This operation requires IIS integrated pipeline mode" exception. Just make sure you're running IIS 7 and you'll be good.