解决在aspx页面上进行传中文参数时会出现乱码问题

解决办法有两种:

其一,在web配置文件中将

 <globalization requestEncoding="utf-8" responseEncoding="utf-8"

改为:

<globalization requestEncoding="GB2312" responseEncoding="GB2312"/>

但是这样可能会引起其它页面显示问题,要权衡使用。

 

其二,在发送请求页面和接收请求页面,使用强制编码和编码之后的转换

发送页面:

string strResponse;

//转换为中文编码

strResponse= HttpUtility.UrlEncode(strResponse,System.Text.Encoding.GetEncoding("GB2312"));

接收页面

string strResponse;

//还原
System.Collections.Specialized.NameValueCollection URLgb2312 = HttpUtility.ParseQueryString(Request.Url.Query, System.Text.Encoding.GetEncoding("GB2312"));

reportName = URLgb2312["strResponse"];
       

 

 

 

posted on 2009-06-27 16:35  lumnm  阅读(660)  评论(0编辑  收藏  举报

导航