IE下載中文檔名出現亂碼
當瀏覽器是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/2008/04/20/ASPNET-Force-Download-File-and-deal-with-Chinese-Filename-correctly.aspx
UrlPathEncode 用於檔案下載出現亂碼的問題
http://paladinprogram.blogspot.tw/2012/07/urlpathencode.html
頁:
[1]