在Firefox中需要把filename 用双引号包起来,才能得到想要的名字,不然如果含有空格,会丢掉空格后面的部分。
而IE会把空格转为_,因此也需要HttpUtility.UrlPathEncode方法处理下名字。
如果Firefox中也用HttpUtility.UrlPathEncode处理名字,空格将被替换成"%20".

 1              HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ContentType = "Application/pdf";
string doc1 = System.IO.Path.GetFileNameWithoutExtension(doc) + "_" + intNewID.ToString() + ".pdf"; if(HttpContext.Current.Request.Browser.Browser != "IE")
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=\"" +doc1+"\"");
else
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename="+ HttpUtility.UrlPathEncode( doc1));
byte[] buffer=System.IO.File.ReadAllBytes(doc);
HttpContext.Current.Response.AddHeader("Content-Length", buffer.Length.ToString());
HttpContext.Current.Response.BinaryWrite(buffer);

最新文章

  1. Inkpad绘图原理浅析
  2. UIStepper步进器 ——事件驱动型控件,(一个+和-按钮的)
  3. 深拷贝 vs 浅拷贝 释放多次
  4. 【bzoj1029】道路抢修
  5. Java基础 —— Java常用类
  6. 2014-9-17二班----7 web project
  7. Linux配置vpn
  8. WKWebView不显示提示框(Swift)
  9. PL/SQL学习(二)条件和循环语句
  10. Eclipse超级完美汉化教程
  11. htm初学笔记
  12. android ListView优化
  13. 2015 asia xian regional F Color (容斥 + 组合数学)
  14. 如何正确使用Java异常处理机制
  15. Spring Boot入门(二):使用Profile实现多环境配置管理&如何获取配置文件值
  16. 兼容IE-FireFox-Chrome的背景音乐播放
  17. 2017.5.10 MapReduce内部逻辑
  18. ASP正则匹配方法
  19. Python—— *与** 参数说明
  20. DOS建立带点的文件夹

热门文章

  1. Oracle数据库获取uuid函数
  2. 寻找第K大 网易2016实习研发工程师编程题
  3. JDK线程池的实现
  4. Data Structure Binary Tree: Iterative Postorder Traversal
  5. iOS项目中获取验证码倒计时及闪烁问题解决方案
  6. Windows Server 2008无损调整分区的方法
  7. CDH- 集群时间同步ntp问题解决
  8. linux shell编程(三) if 和 for
  9. 模拟C#的事件处理和属性语法糖
  10. jQuery横向手风琴图片滑块