[C#] 纯文本查看 复制代码 string psdata = "{\"Account\":\"" + Account + "\",\"Password\":\"" + Password + "\",\"MoneyPassword\":\"" + MoneyPassword + "\",\"Name\":\"" + Name + "\",\"checkCode\":\"" + checkCode + "\",\"checkCodeEncrypt\":\"" + checkCodeEncrypt + "\"}";
item = new HttpItem()
{
URL = registUrl,
Method = "post",
Cookie = cookie,
Host = host,
UserAgent = agent,
ProxyIp = "127.0.0.1:8888",
ContentType = "application/json;charset=UTF-8",
Accept = "application/json, text/plain, */*",
PostDataType = PostDataType.Byte,
PostdataByte = HttpHelper.StringToByte(psdata),
PostEncoding=System.Text.Encoding.UTF8,
};
Console.WriteLine("psd==="+psdata);
item.Header.Add("X-Requested-With", "XMLHttpRequest");
result = http.GetHtml(item);
以上是我做提交时候的代码,控制台打印的提交数据是
[C#] 纯文本查看 复制代码 psd==={"Account":"sdfkljk","Password":"sdfkljk","MoneyPassword":"sdfkljk","Name":"中华伟大的祖国啊","checkCode":"4786","checkCodeEncrypt":"GJlUNIwAIMVGPVZYHFj9Jw=="}
但是我通过fiddler抓包却发现提交的数据是[C#] 纯文本查看 复制代码 {"Account":"sdfkljk","Password":"sdfkljk","MoneyPassword":"sdfkljk","Name":" л ΰ ","checkCode":"4786","checkCodeEncrypt":"GJlUNIwAIMVGPVZYHFj9Jw=="}
如果英文提交都正常,就是提交中文名称的时候就出现乱码,求解决方式。我知道是编码格式问题,但是服务器端要求是UTF-8编码,我也设置了该格式,而且这已经不是服务器端的问题,而是我客户端提交的时候就不正常。 |