D493829844
邓燕华
采纳率50%
2014-08-20 04:40 阅读 3.3k

(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();

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐