Code to test WebRequest and WebResponse

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Net;

using System.IO;

 

namespace ReadWebsite

{


class
Program

{


static
void Main(string[] args)

{


WebRequest request = WebRequest.Create(http://www.microsoft.com”);


WebResponse response = request.GetResponse();

 


StreamReader responseStream = new
StreamReader(response.GetResponseStream());


string reponseText = responseStream.ReadToEnd();

 


Console.WriteLine(reponseText);


Console.Read();

 

response.Close();

}

}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s