Simple HTTP request and response

For getting programmatically the HTML content of a web page:


using System.Net;

public string GetPage(string pageToGet)
{
HttpWebRequest request= (HttpWebRequest)HttpWebRequest.Create(pageToGet);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

return new streamReader(response.GetResponseStream()).ReadToEnd();

}

No comments: