郁闷,继续散分问问题
事情是这样的
我用c#使用get方法提交了一些数据到http服务器
可是服务器端收到的中文数据都是乱码,然后我用nc看ie和我的程序提交的数据,的确不一样
这是ie提交的
C:\>nc -l -p 80
GET /iface/Send.jsp?cid=801&mid=13909181595&con=哈哈&usr=test8&pwd=test8 HTTP/1.
1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-
excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwav
e-flash, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Maxthon; SV1; .NE
T CLR 1.1.4322)
Host: 127.0.0.1
Connection: Keep-Alive
这是我的程序提交的
C:\>nc -l -p 80
GET /iface/Send.jsp?cid=801&mid=13909181595&con=%E6%B5%8B%E8%AF%95&usr=test8&pwd
=test8 HTTP/1.1
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: 127.0.0.1
看看
ie提交的
con=哈哈
是正确的
我提交的
con=%E6%B5%8B%E8%AF%95
就不对了
程序如下
string URL1="http://127.0.0.1/iface/Send.jsp?cid=801&mid="+mID+"&con="+ (textBox2.Text)+"&usr=test8&pwd=test8";
try
{
WebRequest wrqst=WebRequest.Create(URL1);
wrqst.Headers.Add("Accept-Language","en-us");
wrqst.Headers.Add("Accept-Encoding","gzip, deflate");
//wrqst.Method="GET";
WebResponse WResp = wrqst.GetResponse();
// get the stream of data
StreamReader sr = new StreamReader(WResp.GetResponseStream(), Encoding.ASCII);
string strTemp = "";
while ((strTemp = sr.ReadLine()) != null)
{
strSource.Append(strTemp + "\r\n");
}
sr.Close();
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message);
}
MessageBox.Show(strSource.ToString());
提交上去的汉字就是乱的!