Hi
I want to display the html content of the web pages(url address) in a c# window applications, but it is possible to get the dynamic content of a web pages also.
If yes please query your comment.
Hi
I want to display the html content of the web pages(url address) in a c# window applications, but it is possible to get the dynamic content of a web pages also.
If yes please query your comment.
You can easily fetch the html content of the any URL into the string using the string builder and webrequest .net classes. Refer this link for the sample code.
http://ask4asp.net/post/2009/05/13/fetching-URL-contents-into-a-string-using-HttpWebRequest.aspx
If you are looking just to display the URL in the windows form then there is one component available named WebBrowser in C#.
Also take a look at "mshtml".
Try code
private string GetHtmlFromUrl(string url)
{
string html = "";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// get the response stream.
//Stream responseStream = response.GetResponseStream();
// use a stream reader that understands UTF8
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
html = reader.ReadToEnd();
// close the reader
reader.Close();
response.Close();
return html;//return conten html
}
If you just want to display the webpage as it appears in your browser then the WebBrowser control is the easiest way to go. You jsut set the URL and it works like any other webbrowser, but its a control embedded in your program.
If you just want to display the webpage as it appears in your browser then the WebBrowser control is the easiest way to go. You jsut set the URL and it works like any other webbrowser, but its a control embedded in your program. this Click Here
in C# WebResponse return a StreamReader and we can get the content from StreamReader ..
WebResponse webresponse ;
webRequest = WebRequest.Create(textBox1.Text);
webresponse = webRequest.GetResponse();
inStream = new StreamReader(webresponse.GetResponseStream());
textBox2.Text = inStream.ReadToEnd();
full source code...Get URL Content
Nathan
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.