Difference between WebClient and HttpWebRequest/Response??

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.
 
F

Feroze [msft]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top