惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
G
Google Developers Blog
MyScale Blog
MyScale Blog
Google DeepMind News
Google DeepMind News
J
Java Code Geeks
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Proofpoint News Feed
D
Docker
Jina AI
Jina AI
博客园 - 三生石上(FineUI控件)
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
T
Tailwind CSS Blog
N
Netflix TechBlog - Medium
Forbes - Security
Forbes - Security
MongoDB | Blog
MongoDB | Blog
Attack and Defense Labs
Attack and Defense Labs
Webroot Blog
Webroot Blog
A
About on SuperTechFans
Schneier on Security
Schneier on Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
Microsoft Azure Blog
Microsoft Azure Blog
F
Fortinet All Blogs
IT之家
IT之家
The Last Watchdog
The Last Watchdog
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
Project Zero
Project Zero
B
Blog
Recorded Future
Recorded Future
博客园_首页
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
SegmentFault 最新的问题
Security Archives - TechRepublic
Security Archives - TechRepublic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hacker News: Front Page
T
Threatpost
H
Heimdal Security Blog
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog

博客园 - KevinWang

Server.HtmlEncode vs HttpUtility.HtmlEncode 序列化,反序列化时低序位非打印 ASCII 字符的问题 - KevinWang 月薪上万的人都懂得这些道理 c# .ToString()格式化 利用ListView和DataPager控件来对数据分页 PageMethods Not Found (or Defined)? (转) asp.net中使用ajax中的三种方式 Asp.Net2.0技巧 - KevinWang - 博客园 虚方法(virtual)和抽象方法(abstract)的区别 数据库设计经验之谈(转载) 网站令浏览器崩溃的原因 各种流行的编程风格 2009年海外Web设计风潮 常用js框架,js库 硬盘RAID是什么意思?有什么用? T-SQL和PL/SQL 区别 What is PL/SQL?(PL/SQL是什么,与T-SQL对比) 数据库和数据仓库的区别 ASP.NET MVC 资料
在FireFox IE 下Response 中文文件名乱码问题
KevinWang · 2011-05-23 · via 博客园 - KevinWang

发现很多园子里的人在处理Response 下载文件名是使用这个方法

Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileInfo.Name, System.Text.Encoding.UTF8));

但这个只是针对没有空格和IE的情况下使用。

如果想在FireFox下输出没有编码的文件,并且IE下输出的文件名中空格不为+号,就要多一次判断了。

if (Request.UserAgent.ToLower().IndexOf("msie") > -1)

    downloadfilename = HttpUtility.UrlPathEncode(downloadfilename);

if (Request.UserAgent.ToLower().IndexOf("firefox") > -1)

    Response.AddHeader("Content-Disposition""attachment;filename=\"" + downloadfilename + "\"");

    Response.AddHeader("Content-Disposition""attachment;filename=" + downloadfilename);