The WebClient is located in the system. Net namespace. This class allows you to easily create HTTP requests and obtain the returned content.
I. Usage 1- Downloaddata String Uri = " Http://coderzh.cnblogs.com " ;
WebClient WC = New WebClient ();
Console. writeline ( " Sending an http get request " + Uri );
Byte [] Bresponse = WC. downloaddata (URI );
String Strresponse = Encoding. ASCII. getstring (bresponse );
Console. writeline ( " HTTP response is: " );
Console. writeline (strresponse );
Ii. Usage 2- Openread
String Uri = " Http://coderzh.cnblogs.com " ;
WebClient WC = New WebClient ();
Console. writeline ( " Sending an http get request " + Uri );
Stream St = WC. openread (URI );
Streamreader SR = New Streamreader (ST );
String Res = Sr. readtoend ();
Sr. Close ();
St. Close ();
Console. writeline ( " HTTP response is " );
Console. writeline (RES );