System.Net.WebRequest is an abstract class, System.Net.HttpWebRequest and System.Net.FileWebRequest will inherit the WebRequest.
The System.Net.WebClient class provides common methods for sending data to or receiving data from any local, intranet, or Internet resource identified by a URI. The WebClient class uses the WebRequest class to provide access to resources. WebClient instances can access data with any WebRequest descendant registered with the WebRequest.RegisterPrefix method.
The System.Net.Http.HttpClient class is a base class for sending HTTP requests and receiving HTTP responses from a resource identified by a URI.
The .NET 2.0 included WebClient class to communicate with web server using HTTP protocol. However, WebClient class had some limitations. The .NET 4.5 includes HttpClient class to overcome the limitation of WebClient. Microsoft doesn't recommend that you use the WebClient class for new development. Instead, use the System.Net.Http.HttpClient class.
WebClient
|
HttpClient
|
Available in older version of .NET |
.NET 4.5 or later version. 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. |