asp.net 中 ajax 传递数据出现乱码的问题

asp.net中在用ajax格式传递数据到aspx页面时有时会出现乱码,以下为解决方法

js中 :  XmlHttp.open("POST", "test.aspx", false);
        XmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
       
        XmlHttp.send("QueryName=" + escape(Queryname) + "&QuerySex=" +escape(Querysex));

在test.aspx中 :

        string   QueryName = HttpUtility.UrlDecode(Request.Params["QueryName"]);
        string   QuerySex = HttpUtility.UrlDecode(Request.Params["QuerySex"]);

这样获取到的数据就不会出现乱码了

原文地址:https://www.cnblogs.com/zhiqiu/p/2425787.html