Below i am using a function that takes a web page full url as string and return back HTML of that page as string. You can
use this returned HTML in your code as per your requirement.
Step 1:
First import 2 namespaces that are required by this function to work.
using System.IO;
using System.Net;
Step 2:
Copy & Paste this function in your code behind.
public string GetHTML(string strURL)
{
HttpWebRequest wbrq = (HttpWebRequest)WebRequest.Create(strURL);
wbrq.Method = “GET”;
HttpWebResponse wbrs = (HttpWebResponse)wbrq.GetResponse();
StreamReader sr = new StreamReader(wbrs.GetResponseStream());
strResult = sr.ReadToEnd();
sr.Close();
return strResult;
}
Step 3:
Call this function as per your requirement.
string strHtml=this.GetHTML(“http://www.google.com”);
Happy Programming 🙂