Difference between WebClient and HttpWebRequest/Response??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the difference (pros and cons) between retrieving data from the web
using System.Web.WebClient and using HttpWebRequest and Response to get the
data? The WebClient download methods seem to neatly encapsulate the multiple
steps (request.Create; request.GetResponse; response.GetResponseStream ...)
required with the traditional HttpWebRequest/Response approach. I am trying
to crawl urls and download data.
 
In short, HttpWebRequest gives you more fine grained control over your
request. WebClient does not. It encapsulates most of the stuff for you.

WebClient is very useful if you want to do specialized, one-off tasks, eg:
download file, do forms post etc.

HttpWebRequest is useful if you want to do more complicated stuff.
 
Back
Top