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.

Recommended Answers

All 6 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.