Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Get HTML Source of Webpage

0.00/5 (No votes)
22 Oct 2013 1  
HTML source code of any website/webpage.

Introduction 

The article is regarding how to get the HTML source of any webpage without being redirected to a particular webpage.

Using the code

Go through the following code to know how to get the HTML source from any webpage without being redirected in ASP.NET:

static string GetHtmlPage(string strURL)
{
    String strResult;
    WebResponse objResponse;
    WebRequest objRequest = HttpWebRequest.Create(strURL);
    objResponse = objRequest.GetResponse();
    using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
    {
        strResult = sr.ReadToEnd();
        sr.Close();
    }
    return strResult;
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here