响应内容配置文件名编码

时间:2012-09-07 09:01:16

标签: c# string response

我想从ASP.net保存/打开一个文件。

if (Request.Browser.Browser == "IE" && (Request.Browser.Version == "7.0" || Request.Browser.Version == "8.0" || Request.Browser.Version == "9.0"))
contentDisposition = "inline; filename=" + Uri.EscapeDataString(fileName);
else
contentDisposition = "inline; filename*=UTF-8''" + Uri.EscapeDataString(fileName);

Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Charset = "UTF-8";
Response.ContentType = "application/" + mimeType;
Response.AppendHeader("content-disposition", contentDisposition + "." + extension);

通过这个例子áéááasd.pdf,我得到以下áéáá%20asd.pdf。 而不是%20,我想要一个简单的空间。

1 个答案:

答案 0 :(得分:0)

使用字符串的替换方法,这里的示例: string result = filename.Replace("%20"," ")方法