1、不带参数的POST请求
public static string Post(string url)
{
string result = ;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = POST;
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
//获取内容
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
result = reader.ReadToEnd();
}
return result;
}
2、带参数的POST请求
3、不带参数的GET请求
4、带参数的GET请求
5、自定义HTTP请求头