protected void Page_Load(object sender, EventArgs e)
{
string aa= httpRequest("http://www.baidu.com");
}
//httP请求
public static string httpRequest(string url)
{
WebRequest req = WebRequest.Create(url);
WebResponse res = req.GetResponse(); // GetResponse blocks until the response arrives
Stream ReceiveStream = res.GetResponseStream(); // Read the stream into a string
StreamReader sr = new StreamReader(ReceiveStream);
string resultstring = sr.ReadToEnd();
return resultstring;
}
(摘自:http://www.cnblogs.com/tuyile006/archive/2008/11/14/1333632.html)