I recently started learning and writing WebAPI services rather WCF REST services.
While consuming WebAPI services, I learned the below differences between WebClient and HttpClient.
WebClient
|
HttpClient
|
| Available in older version of .NET | .NET 4.5 only. Created to support the growing need of the Web API REST calls |
| WinRT applications cannot use WebClient | HttpClient can be used with WinRT |
| Provides progress reporting for downloads. | No progress reporting for downloads. |
| Does not reuse resolved DNS, configured-cookies. | Can reuse resolved DNS, cookie configuration, and other authentication. |
| You need to new up a WebClient to make the concurrent request. | Single HttpClient can make concurrent requests. |
| Thin layer over WebRequest and WebResponse | Thin layer over HttpWebRequest and HttpWebResponse |
| Mocking and testing WebClient is difficult | Mocking and testing HttpClient is easy |
| Supports FTP. | No support for FTP. |
| Both synchronous and Asynchronous methods are available for IO bound requests. | All IO bound methods in HTTPClient are asynchronous. |
Refernces: http://www.diogonunes.com/blog/webclient-vs-httpclient-vs-httpwebrequest/
https://stackoverflow.com/a/27737601/405317
No comments:
Post a Comment