request 接受 xmlhttp post 过来的 requeststring 字段 ,数字显示正常 ,中文是一对乱码,怎么回事 ? request 接受 xmlhttp post 过来的 requerystring 字段 ,数字显示正常 ,中文是一堆乱码,怎么回事 ? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 post的时候编码js用escape函数,.net用Server.UrlEncode函数 有Server.UrlEncode("")进行编码后进行传递,再用Server.UrlDecode("")进行解码即可 xmlhttp 在js里面还是在cs里面? xmlhttp 在 aspx js 里 ,创建和发送 ,在 aspx.cs 里 ,request 该字段时,接受到的是中文 乱码,数字和符号则正常 xmlhttp写成类似这样var querystring='a='+escape('中国')+'&b='+escape('美国')xmlhttp.open("post", "abcd.aspx", true); xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlhttp.send(querystring); 如果不改编码的情况下,可以采用 jinjazz 的方法否则 要在web.config 中设置如下节点 <system.web> <globalization requestEncoding ="GB2312" responseEncoding ="GB2312"/> </system.web> 找到文件"C:\WINNT\Microsoft.NET\Framework\版本号\CONFIG\Machine.config将语句<globalization requestEncoding="UTF-8"requestEncoding="UTF-8"/>中2个UTF-8改成GB2312 页面是 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />js 是 if(window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } xmlHttp.open("POST", webFileUrl, false); xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); xmlHttp.send(""); result = xmlHttp.responseText;web.config 里 添加 <globalization requestEncoding ="GB2312" responseEncoding ="GB2312"/>后 在 ie 里中文正常显示 ,在 firefox 里 是乱码去掉 <globalization requestEncoding ="GB2312" responseEncoding ="GB2312"/>后 ie 里中文乱码显示 ,在 firefox 里 是正常 !怎么办 ????? 页面是 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />js 是 if(window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } xmlHttp.open("POST", webFileUrl, false); xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); xmlHttp.send(""); result = xmlHttp.responseText;web.config 里 添加 <globalization requestEncoding ="GB2312" responseEncoding ="GB2312"/>后 在 ie 里中文正常显示 ,在 firefox 里 是乱码去掉 <globalization requestEncoding ="GB2312" responseEncoding ="GB2312"/>后 ie 里中文乱码显示 ,在 firefox 里 是正常 !怎么办 ????? ok ! 用 jinjazz 的方法 ,解决了问题 !谢谢 jinjazz ! 省,市,县级联效果 embed标签,急用!!! 请问下怎么清除cookie? AOP的选择 动态添加时间段的问题 在DataGrid里加入RadioButton列,单选的问题? 如何将一个数据库中几个属性相同的表的数据相加? 关于XML 在线播放问题,麻烦遇见过的帮忙哈! 关于.net打印的问题 提交后,怎么清空表单中的数据啊 Repeater如何求列的合计啊
js用escape函数,.net用Server.UrlEncode函数
在 aspx.cs 里 ,request 该字段时,接受到的是中文 乱码,数字和符号则正常
xmlhttp写成类似这样var querystring='a='+escape('中国')+'&b='+escape('美国')xmlhttp.open("post", "abcd.aspx", true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.send(querystring);
<globalization requestEncoding ="GB2312" responseEncoding ="GB2312"/>
</system.web>
将语句<globalization requestEncoding="UTF-8"requestEncoding="UTF-8"/>
中2个UTF-8改成GB2312
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
xmlHttp.open("POST", webFileUrl, false);
xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlHttp.send("");
result = xmlHttp.responseText;web.config 里 添加 <globalization requestEncoding ="GB2312" responseEncoding ="GB2312"/>
后 在 ie 里中文正常显示 ,在 firefox 里 是乱码
去掉 <globalization requestEncoding ="GB2312" responseEncoding ="GB2312"/>
后 ie 里中文乱码显示 ,在 firefox 里 是正常 !怎么办 ?????
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
xmlHttp.open("POST", webFileUrl, false);
xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlHttp.send("");
result = xmlHttp.responseText;web.config 里 添加 <globalization requestEncoding ="GB2312" responseEncoding ="GB2312"/>
后 在 ie 里中文正常显示 ,在 firefox 里 是乱码
去掉 <globalization requestEncoding ="GB2312" responseEncoding ="GB2312"/>
后 ie 里中文乱码显示 ,在 firefox 里 是正常 !怎么办 ?????
的方法 ,解决了问题 !谢谢 jinjazz !