2 d493829844 D493829844 于 2014.08.20 12:40 提问

(HttpWebRequest)WebRequest.Create(url),url带中文参数编码之后请求不到数据

代码:
string name = System.Web.HttpUtility.UrlEncode("广州");
string url = "http://172.22.1.175/di/http.action?userId=idc&pwd=idcpwd&interfaceId=getRACAwst4City&dataFormat=xml&city=" + name + "&ymd=20140811&hm=0800";

HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(TheURL);
//接受请求
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Stream receiveStream = myHttpWebResponse.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, System.Text.Encoding.GetEncoding("GB2312"));
//此为要取页面的返回值输出的返回结果
returnValue = readStream.ReadToEnd();

Csdn user default icon
上传中...
上传图片
插入图片