我正在使用在HttpHandler子项中实现的HttpContext对象来下载文件,当我在文件名中有非ascii字符时,它在IE中看起来很奇怪,而在Firefox中看起来很好.
以下是代码: -
context.Response.ContentType = ".cs";
context.Response.AppendHeader("Content-Length", data.Length.ToString());
context.Response.AppendHeader("Content-Disposition", String.Format("attachment; filename={0}",filename));
context.Response.OutputStream.Write(data, 0, data.Length);
context.Response.Flush();
Run Code Online (Sandbox Code Playgroud)
当我在文件名称字段中提供"嗯""澶'Ã'那张"A 3""嗯""澶'Ã'那张"A 3"它看起来比不同我有什么文件在Firefox中看起来很好看.添加EncodingType和charset一直没用.
在IE中它是'ÃÂ' 'ä' 'ÃÂ' 'ü' 'ó' 'ÃÂ' 'ä' 'ÃÂ' 'ü' _ 'ó',并在Firefox是'嗯'" Ã''''''''''''''''''''''''''''''''''''''''''''''''
任何想法如何解决这个问题?