在关闭缓存的情况下通过 .ashx 文件下载文件时出现 IE 错误
我有一个简单的“文件下载”通用处理程序,它在通过相同响应发送文件之前设置响应内容类型和标头。
我还在 global.asax 中设置了 Response.Cache.SetCacheability(HttpCacheability.server) 。
正如我从各种来源注意到的那样,Internet Explorer 不喜欢这种无缓存设置,并且在尝试下载文件时会出现错误(请求的站点不可用或无法找到)。
我想也许我可以覆盖 .ashx 页面中的此设置,因此我将响应的可缓存性设置更改为公共。这并没有解决问题...从 global.asax 中删除该行确实解决了问题,但显然会影响整个站点。
有没有办法为我的通用处理程序设置可缓存性?
干杯:D
I have a simple 'file download' generic handler which sets the response contenttype and headers before sending the file through the same response.
I also have Response.Cache.SetCacheability(HttpCacheability.server) set in the global.asax.
As I have noticed from various sources, Internet Explorer doesn't like this no-cache setting and gives an error when trying to download the file (requested site unavailable or cannot be found).
I thought maybe I could override this setting in the .ashx page, so I alter the response's cacheability setting to public. This did not solve the issue... removing the line from global.asax does solve the problem but obviously affects the whole site.
Is there a way of setting the cachability just for my generic handler?
Cheers :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能否仅检查是否向通用处理程序发出请求并根据结果提供适当的缓存设置?像这样的事情:
Can you just check whether the request is made to your generic handler and provide the appropriate cache settings depending on the result ? Something like this: