C#在传中文值会出现乱码的解决方法:

来源:互联网 发布:自主车企实力 知乎 编辑:程序博客网 时间:2024/04/29 15:47

1)
Response.Redirect("download.aspx?path=" + HttpContext.Current.Server.MapPath("~/现场安装单信息.xls") + "&FileName=" + HttpUtility.UrlDecode("现场安装单信

息.xls"));

download.aspx.cs

String strrealpath = Request.QueryString["path"].ToString();
string filename = Request.QueryString["FileName"].ToString();
Download(HttpUtility.UrlDecode(strrealpath), HttpUtility.UrlDecode(filename));

2)
public string strFileName = "中文V1.pdf";
public string strDownLoadFileName = "中文V1.pdf";

strDownLoadFileName = HttpUtility.UrlEncode(strDownLoadFileName);
strFileName = HttpUtility.UrlEncode(strFileName);

<a href="download.aspx?path=d:\download\<%=strDownLoadFileName%>&FileName=<%=strFileName%>" target="_blank" style="text-decoration:underline">帮助文

档下载</a>

download.aspx.cs
string strrealpath = Request.QueryString["path"].ToString();
string filename = Request.QueryString["FileName"].ToString();
Download(HttpUtility.UrlDecode(strrealpath), HttpUtility.UrlDecode(filename));

0 0
原创粉丝点击