ASP.NET
IE下載中文檔名出現亂碼
1
#
JDP
6251
0
2014-6-27 11:12:03
當瀏覽器是IE時,利用UrlPathEncode編碼來解決亂碼問題
protected void btnDownload_Click(object sender, EventArgs e)
{
string str = "測 試.doc";
if (context.Request.Browser.Browser == "IE")
str = HttpUtility.UrlPathEncode(str);
else
str = string.Format(""{0}"", str);
Context.Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", str));
}
複製代碼
Reference:
ASP.NET 如何設定強制下載檔案並正確處理中文檔名的問題
http://blog.miniasp.com/post/200 ... name-correctly.aspx
UrlPathEncode 用於檔案下載出現亂碼的問題
http://paladinprogram.blogspot.tw/2012/07/urlpathencode.html
倒序瀏覽
看全部
全部回復
暫無回復,快來搶沙發
回復
收藏
轉播
分享
淘帖