request 接受 xmlhttp post 过来的 requerystring 字段 ,数字显示正常 ,中文是一堆乱码,怎么回事 ? 

解决方案 »

  1.   

    post的时候编码
    js用escape函数,.net用Server.UrlEncode函数
      

  2.   

    有Server.UrlEncode("")进行编码后进行传递,再用Server.UrlDecode("")进行解码即可
      

  3.   

    xmlhttp 在js里面还是在cs里面?
      

  4.   

    xmlhttp 在 aspx js 里 ,创建和发送 ,
    在 aspx.cs 里 ,request 该字段时,接受到的是中文 乱码,数字和符号则正常
      

  5.   


    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);
      

  6.   

    如果不改编码的情况下,可以采用 jinjazz 的方法否则 要在web.config 中设置如下节点 <system.web>
        <globalization requestEncoding ="GB2312" responseEncoding ="GB2312"/>
     </system.web>
      

  7.   

    找到文件"C:\WINNT\Microsoft.NET\Framework\版本号\CONFIG\Machine.config
    将语句<globalization requestEncoding="UTF-8"requestEncoding="UTF-8"/>
    中2个UTF-8改成GB2312
      

  8.   

    页面是 <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 里 是正常 !怎么办 ?????
      

  9.   

    页面是 <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 里 是正常 !怎么办 ?????
      

  10.   

    ok ! 用 jinjazz
     的方法 ,解决了问题 !谢谢 jinjazz !