How to get Html Source Code using WebRequest in C#
How to get HTML source code using Web Request in C#:
In this article am going to explain you how to get the HTML source of an url with web request:
In order to implement this please have a look at bellow code:
HttpWebRequest WebReq = (HttpWebRequest)HttpWebRequest.Create(MyUrl);
WebReq .Method = "GET";
HttpWebResponse WebRes = (HttpWebResponse)WebReq .GetResponse();
StreamReader WebSourceStream = new StreamReader(WebRes .GetResponseStream());
string PageSource = string.Empty;
PageSource = WebSourceStream .ReadToEnd();
WebRes .Close();
I hope this will helps you in dev