那是文件编码方面的问题吧,附件好象是BASE64编码
解决方案 »
- 求助,数据如何实现这种表现形式
- 急...在线等...
- 关于VS2005的树型控件的问题(跪求啊)
- 脚本更新textbox,发现它不再保持状态,有办法吗
- 救急!!!DataGrid自定义分页,在有些页面发现会执行2次,翻2页
- 一个页面间数据访问的问题
- 同一个项目中,如何从B.aspx.cs页面调用A.aspx.cs中的方法和函数呢?????
- Exception Details: System.Data.OleDb.OleDbException: 用户 'FLY\ASPNET' 登录失败。
- 使用HttpHandler的站点如何“把文件扩展名注册到IIS”?
- 为什么js文件中有中文时,使用就会出现错误?如何解决或者避免?
- 能不能在服务器端控制浏览器的地址栏的历史纪录?也就像这样(请进去看看)
- nt4.0上运行asp.net所需的安装步骤?
我是这样做的,可是还是无法正确显示中文文件名,而是b++ ++.doc
dim strfile as string = server.urlencode("中文.doc")
response.appendheader("content-disposition","attachment;filename=" & strfile)
我还拉下那些需要的设置没有做吗?
感谢大家讨论这个问题,给我的帮助.
Response.AppendHeader("Content-Language","zh");Response.AppendHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fileName));
这是我的代码
其实楼上的方法是可行的,但有局限性关键在于UrlEncode这个东东,在下面不同情况下的结果是不一样的
1。web.config 里responseEncoding="gb2312"
2。web.config 里responseEncoding="utf-8"
使用Server.UrlEncode的话必须responseEncoding="utf-8"才会正确
所以不要用Server.UrlEncode,换HttpUtility.UrlEncode
string s=HttpUtility.UrlEncode(System.Text.UTF8Encoding.UTF8.GetBytes("中文.txt"));
Response.AppendHeader("Content-Disposition", "attachment; filename=" + s);
例子如下:
Response.AppendHeader("Content-Disposition", "attachment;Content-Type:" + fileType + ";Content-Transfer-Encoding: base64;filename=" + Server.UrlEncode(fileName ));
string s=HttpUtility.UrlEncode(System.Text.UTF8Encoding.UTF8.GetBytes("中 文.txt")).Replace('+',' ');
那么使用编码的时候,就必须使用HttpUtility.UrlEncode(System.Text.UTF8Encoding.UTF8.GetBytes("中文.txt"));
是吗?