Difference between WebClient and HttpWebRequest/Response
-
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.
-
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.
Hi Jason, As you already know that the WebClient class in fact uses the WebRequest internally to make a connection to the remote resource, and the HttpWebRequest is just a descendant of the abstract basic WebRequest class. The way I see it is the WebClient class provides the user with an easy and simple way to connect to request data from the remote resource, because it encapsulates the basic steps which you should have to do by yourself if you use the WebRequest. However, with the WebRequest and its descendants you will have more control to handle the way to request data from the remote resource. For more information, you can see Requesting Data[^]