您的位置:首页 > 编程语言 > ASP

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

2009-06-27 16:35 357 查看
解决办法有两种:

其一,在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"];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: