The 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.
Note: |
|---|
By default, the .NET Framework supports
URIs
that begin with
http:, https:, ftp:, and file: scheme identifiers.
|
The following table describes WebClient methods for uploading data to a resource.
The following table describes WebClient methods for downloading data from a resource.
You can use the CancelAsync method to cancel asynchronous operations that have not completed.
A WebClient instance does not send optional HTTP headers by default. If your request requires an optional header, you must add the header to the Headers collection. For example, to retain queries in the response, you must add a user-agent header. Also, servers may return 500 (Internal Server Error) if the user agent header is missing.
AllowAutoRedirect is set to true in WebClient instances.
Notes to Inheritors:
Derived classes should call the base class implementation of WebClient to ensure the derived class works as expected.