asp.net中在用ajax格式传递数据到aspx页面时出现乱码

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