C#post请求发送json数据包|get获取数据包
1 | public string PostXmlResponse(string url, string xmlString) |
public static HttpWebResponse CreateGetHttpResponse(string url)
{
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = “GET”;
request.ContentType = “application/x-www-form-urlencoded”;//链接类型
return request.GetResponse() as HttpWebResponse;
}
///
/// 从HttpWebResponse对象中提取响应的数据转换为字符串
///
///
///
public string GetResponseString(HttpWebResponse webresponse)
{
using (Stream s = webresponse.GetResponseStream())
{
StreamReader reader = new StreamReader(s, Encoding.UTF8);
return reader.ReadToEnd();
}
}`