using System;
using System.Net;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// example 1
using (var client = new WebClient())
{
string htmlText = client.DownloadString("cprogramming.bootzlabs.com");
Console.WriteLine(htmlText);
}
// example 2
try
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("www.webshopy.com");
WebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string htmlText = reader.ReadToEnd();
reader.Close();
response.Close();
Console.WriteLine(htmlText);
}
catch (WebException we)
{
Console.WriteLine(we.ToString());
}
}
}
}