PDF下载失败,显示消息"无法下载"只有在IE11 [英] PDF download fails showing message "Couldn't be downloaded" only in IE11

查看:668
本文介绍了PDF下载失败,显示消息"无法下载"只有在IE11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用网络形式ASP.NET的东西,应该是很容易被快把我逼疯了,类似的问题已被要求,但没有人帮我,IE拒绝下载我的文件。

I use ASP.NET with web forms, something that should be really easy is driving me crazy, similar questions have been asked but none of them helped me, IE refuses to download my files.

事情需要注意:


  • 我在本地测试

  • 它工作在Firefox和Chrome,但不是IE11

  • IE修改文件名页面的名称(例如它试图挽救default_aspx代替myfile.pdf)


这是我的code:

Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "Application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.BinaryWrite(buffer);
Response.End();

这是我从IE浏览器得到了标题:

These are the headers I got from IE:

键值

响应HTTP / 1.1 200 OK

Response HTTP/1.1 200 OK

缓存控制私人

内容类型应用程序/ PDF

Content-Type Application/PDF

服务器Microsoft-IIS / 7.5

Server Microsoft-IIS/7.5

内容处置附件;文件名= myfile.pdf

Content-Disposition attachment; filename=myfile.pdf

X-ASPNET-版本4.0.30319

X-AspNet-Version 4.0.30319

X-已启动由ASP.NET

X-Powered-By ASP.NET

日期星期五,2015年4月10日22时44分四十秒GMT

Date Fri, 10 Apr 2015 22:44:40 GMT

的Content-Length 691892

Content-Length 691892

更新

好像这是一个服务器的配置问题,因为同样的code将正常工作在我的生产服务器,但不是在我的开发服务器。
所以我的客户不会抱怨这个,反正我想,只要我有时间,我会研究多一点,如果我找到一个解决方案,我会在这里发布修复它在我的开发环境。

It seems like this is a server configuration issue because the same code will work fine in my production server but not in my development server. So my client won't complain about this, anyway I want to fix it in my development environment, as soon as I have time I'll investigate a little more, if I find a solution I'll post it here.

推荐答案

我们曾在IE8中的类似问题的问题是,文件搜索在缓存中,并没有发现。为了测试这个请将缓存控制:在你的响应对象无缓存

We had a similar issue in ie8 the problem is that the file is searched in the cache and is not found. To test this please set Cache-Control : no-cache in your response object.

这篇关于PDF下载失败,显示消息"无法下载"只有在IE11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆