Category Archives: Uncategorized

How to fetch html from a URL in c#.

Fetching a html from an URL is easy. Class System.Net.HttpWebRequest provides an HTTP – specific implementation of the System.Net.WebRequest class.

using System.IO;
using System.Net;
public void FetchHtml()
{
    string result = string.Empty;
    string url = "http://codesolution.org";
    var request = HttpWebRequest.Create(url);
    using (var response = request.GetResponse())
    {
        result = new StreamReader(response.GetResponseStream()).ReadToEnd();
    }
    div1.InnerHtml = result;
}