Web Services : WebClient vs HttpClient vs HttpWebRequest

Using C# I have found multiple ways to retrieve HTML from a given URL.

  • Using  HttpClient / GetByteArrayAsync / WebUtility.HtmlDecode
  • Using HttpClient / GetAsync /ReadAsStringAsync
  • Using   (HttpWebRequest)WebRequest.Create / (HttpWebResponse)request.GetResponse

 

On top of it,  there is also the HtmlAgilityPack library that lets you load up a web page just by  using the ‘.Load(url)’ method. Check it out here.

 

For beginners it may be a bit perplexing to see these different libraries. I realized this is because of how new libraries got added.

References:

 

Code:

 

 

Advertisements

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