Sometimes a desktop application might need to download a web page to be displayed to the user or screen scrapped. I did this in my MoviePlay application to get the IMDb (The Internet Movie Database) page of the movie. To accomplish this include first the System.IO and System.Net namespaces:
using System.IO; //for StreamReader using System.Net; //for WebClient
The following code needs 3 controls to work; a TextBox (textBox1), a Button (button1), and a WebBrowser (webBrowser1).
private void button1_Click(object sender, EventArgs e)
{
string URL = "http://amgadhs.com/";
WebClient webClient = new WebClient();
StreamReader sr = new StreamReader(webClient.OpenRead(URL));
//pageContent will contain raw HTML
string pageContents = sr.ReadToEnd();
//display the HTML in a TextBox
textBox1.Text = pageContents;
//display the page in a WebBrowser control
webBrowser1.DocumentText = pageContents;
}