当前位置: 移动技术网 > IT编程>开发语言>.net > 中文文件名下载在火狐乱码

中文文件名下载在火狐乱码

2019年02月23日  | 移动技术网IT编程  | 我要评论

百田ゆきな,天蓝色房间,山东彩票彩友沙龙

我们一般下载中文文件名一般会utf-8编码再下载,火狐浏览器会出现文件名乱码,解决办法,火狐浏览器文件名不编码,直接下载:

   httpcontext curcontext = httpcontext.current;

            // 设置编码和附件格式
            curcontext.response.contenttype = "application/vnd.ms-excel";
            curcontext.response.contentencoding = encoding.utf8;
            curcontext.response.charset = "";
            strfilename = strfilename + datetime.now.tostring("yyyymmddhhmmss");

            string useragent = curcontext.request.servervariables["http_user_agent"].tolower();
            if (useragent.indexof("firefox", stringcomparison.ordinal) == -1) 
            {
                strfilename = httputility.urlencode(strfilename, encoding.utf8) + ".xls";
            }
            curcontext.response.appendheader("content-disposition",
                "attachment;filename=" + strfilename);

            curcontext.response.binarywrite(listtoexcel(list, strfilename, titledic).getbuffer());
            curcontext.response.end();

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网