在FireFox IE 下Response 中文文件名乱码问题
生活随笔
收集整理的這篇文章主要介紹了
在FireFox IE 下Response 中文文件名乱码问题
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
發(fā)現(xiàn)很多園子里的人在處理Response 下載文件名是使用這個方法
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileInfo.Name, System.Text.Encoding.UTF8));
但這個只是針對沒有空格和IE的情況下使用。
如果想在FireFox下輸出沒有編碼的文件,并且IE下輸出的文件名中空格不為+號,就要多一次判斷了。
if (Request.UserAgent.ToLower().IndexOf("msie") > -1){downloadfilename = HttpUtility.UrlPathEncode(downloadfilename);}if (Request.UserAgent.ToLower().IndexOf("firefox") > -1){Response.AddHeader("Content-Disposition", "attachment;filename=\"" + downloadfilename + "\"");}else{Response.AddHeader("Content-Disposition", "attachment;filename=" + downloadfilename);}轉(zhuǎn)載于:https://www.cnblogs.com/stangray/archive/2010/06/28/1766884.html
總結(jié)
以上是生活随笔為你收集整理的在FireFox IE 下Response 中文文件名乱码问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Asp.net 服务器端控件
- 下一篇: 【javascript】函数调用的对象和