下载csv,excel文件名乱码的问题(IE和FireFox两种浏览器)
2013-07-09 18:02
435 查看
一.使用ajax与服务器交互 不管是post方式还是get方式都应该对中文进行编码 只有这样 服务器端(ie浏览器 firefox不用)才能正确解析汉字 否则就是乱码。
二.在asp.net MVC中 ie跟firefox对下载文件名的处理不同
/ ie通过编码实现正确的文件名/
public FileContentResult DownLoad()
{
string temp = "我是中国人!";
return File(System.Text.Encoding.UTF8.GetBytes(temp), "text/plain",Url.Encode("中国.txt"));
}
/firefox不必编码否则出现编码后的文件名/
public FileContentResult DownLoad()
{
string temp = "我是中国人!";
return File(System.Text.Encoding.UTF8.GetBytes(temp), "text/plain","中国.txt");
}
兼容firefox跟ie的做法
通过Request.Browser.Browser.ToUpper()来判断是ie还是firefox
详细网址参照:
http://www.cnblogs.com/chengxiaohui/articles/1985163.html
二.在asp.net MVC中 ie跟firefox对下载文件名的处理不同
/ ie通过编码实现正确的文件名/
public FileContentResult DownLoad()
{
string temp = "我是中国人!";
return File(System.Text.Encoding.UTF8.GetBytes(temp), "text/plain",Url.Encode("中国.txt"));
}
/firefox不必编码否则出现编码后的文件名/
public FileContentResult DownLoad()
{
string temp = "我是中国人!";
return File(System.Text.Encoding.UTF8.GetBytes(temp), "text/plain","中国.txt");
}
兼容firefox跟ie的做法
通过Request.Browser.Browser.ToUpper()来判断是ie还是firefox
详细网址参照:
http://www.cnblogs.com/chengxiaohui/articles/1985163.html
相关文章推荐
- 使用Content-Disposition: attachment; filename=FILENAME,在Firefox浏览器中下载文件,文件名中文乱码问题解决。
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- 解决struts2在(IE,Firefox)下载文件名乱码问题
- 解决ie和其他浏览器poi下载excel文件名乱码
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- 解决struts2在(IE,Firefox)下载文件名乱码问题
- [浏览器]IE下载中文文件名乱码问题
- Firefox、IE等浏览器下载文件名中文乱码的一种Server端解决方法
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- JSP文件下载时文件名在ie和firefox下面文件名不一致极其超链接中文乱码的问题的改进
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题
- 解决各大浏览器下载文件乱码以及Firefox下载文件名不全问题