ASP .NET下载文件与日本文件名 [英] ASP .NET Download File with Japanese File Name
问题描述
我目前使用Visual Studio 2008为我的ASP .NET应用程序。我试图通过服务器的Response对象的Excel文件。问题是,我似乎无法设置文件为日语的称号。如果我将它设置为日语的文件名,它就会返回垃圾字符。我使用了WinXP的日本日本的IE浏览器。
I am currently using Visual Studio 2008 for my ASP .NET application. I am trying to server an excel file via the Response object. The problem is I cannot seem to set the title of the file to Japanese. If I set it to Japanese file name, it gets returned as garbage character. I am using a Japanese IE browser in a Japanese WinXP.
Response.AppendHeader("Content-Type", "application/vnd.ms-excel");
Response.AddHeader("Content-Disposition", String.Format("attachment; filename=\"{0}\"", "日本語.xls"));
或
Response.AddHeader("Content-Disposition", String.Format("attachment; filename=\"{0}\"", Server.HtmlEncode("日本語.xls")));
我已经尝试更改编码为Shift-JIS
I already tried to change the encoding to Shift-JIS
Response.Charset = "Shift_JIS";
或
Response.Charset = "sjis";
任何想法?顺便说一句,我曾与Visual Studio 2005中同样的问题了。
Any ideas? Btw, I had the same problem with Visual Studio 2005 too.
推荐答案
我不是ASP专家,但你尝试过使用重新编码UrlEn code中的文件名?
I'm not an ASP expert but have you tried recoding the filename using UrlEncode?
Response.AddHeader("Content-Disposition",
System.Web.HttpUtility.UrlEncode(String.Format("attachment; filename=\"{0}\"", "日本語.xls")));
这篇关于ASP .NET下载文件与日本文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!