HttpClient Class
Provides a base class for sending HTTP requests and receiving HTTP responses from a resource identified by a URI.
Namespace: System.Net.Http
Assembly: System.Net.Http (in System.Net.Http.dll)
The HttpClient type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | HttpClient() | Initializes a new instance of the HttpClient class. |
![]() | HttpClient(HttpMessageHandler) | Initializes a new instance of the HttpClient class with a specific handler. |
![]() | HttpClient(HttpMessageHandler, Boolean) | Initializes a new instance of the HttpClient class with a specific handler and a value that indicates whether this instance is responsible for disposing the handler. |
| Name | Description | |
|---|---|---|
![]() | BaseAddress | Gets or sets the base address of Uniform Resource Identifier (URI) of the Internet resource used when sending requests. |
![]() | DefaultRequestHeaders | Gets the headers which should be sent with each request. |
![]() | MaxResponseContentBufferSize | Gets or sets the maximum number of bytes to buffer when reading the response content. |
![]() | Timeout | Gets or sets the number of milliseconds to wait before the request times out. |
| Name | Description | |
|---|---|---|
![]() | CancelPendingRequests | Cancel all pending requests on this instance. |
![]() | DeleteAsync(String) | Sends a DELETE request to the specified Uri as an asynchronous operation. |
![]() | DeleteAsync(Uri) | Sends a DELETE request to the specified Uri as an asynchronous operation. |
![]() | DeleteAsync(String, CancellationToken) | Sends a DELETE request to the specified Uri with a cancellation token as an asynchronous operation. |
![]() | DeleteAsync(Uri, CancellationToken) | Sends a DELETE request to the specified Uri with a cancellation token as an asynchronous operation. |
![]() | Dispose() | Releases the unmanaged resources and disposes of the managed resources used by the invoker. (Inherited from HttpMessageInvoker.) |
![]() | Dispose(Boolean) | Releases the unmanaged resources used by the HttpClient and optionally disposes of the managed resources. (Overrides HttpMessageInvoker::Dispose(Boolean).) |
![]() | Equals | (Inherited from Object.) |
![]() | Finalize | (Inherited from Object.) |
![]() | GetAsync(String) | Sends a GET request to the specified Uri as an asynchronous operation. |
![]() | GetAsync(Uri) | Sends a GET request to the specified Uri as an asynchronous operation. |
![]() | GetAsync(String, HttpCompletionOption) | Sends a GET request to the specified Uri with an HTTP completion option as an asynchronous operation. |
![]() | GetAsync(String, CancellationToken) | Sends a GET request to the specified Uri with a cancellation token as an asynchronous operation. |
![]() | GetAsync(Uri, HttpCompletionOption) | Sends a GET request to the specified Uri with an HTTP completion option as an asynchronous operation. |
![]() | GetAsync(Uri, CancellationToken) | Sends a GET request to the specified Uri with a cancellation token as an asynchronous operation. |
![]() | GetAsync(String, HttpCompletionOption, CancellationToken) | Sends a GET request to the specified Uri with an HTTP completion option and a cancellation token as an asynchronous operation. |
![]() | GetAsync(Uri, HttpCompletionOption, CancellationToken) | Sends a GET request to the specified Uri with an HTTP completion option and a cancellation token as an asynchronous operation. |
![]() | GetByteArrayAsync(String) | Sends a GET request to the specified Uri and returns the response body as a byte array in an asynchronous operation. |
![]() | GetByteArrayAsync(Uri) | Sends a GET request to the specified Uri and returns the response body as a byte array in an asynchronous operation. |
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetStreamAsync(String) | Sends a GET request to the specified Uri and returns the response body as a stream in an asynchronous operation. |
![]() | GetStreamAsync(Uri) | Sends a GET request to the specified Uri and returns the response body as a stream in an asynchronous operation. |
![]() | GetStringAsync(String) | Sends a GET request to the specified Uri and returns the response body as a string in an asynchronous operation. |
![]() | GetStringAsync(Uri) | Sends a GET request to the specified Uri and returns the response body as a string in an asynchronous operation. |
![]() | GetType | (Inherited from Object.) |
![]() | MemberwiseClone | (Inherited from Object.) |
![]() | PostAsync(String, HttpContent) | Sends a POST request to the specified Uri as an asynchronous operation. |
![]() | PostAsync(Uri, HttpContent) | Sends a POST request to the specified Uri as an asynchronous operation. |
![]() | PostAsync(String, HttpContent, CancellationToken) | Sends a POST request with a cancellation token as an asynchronous operation. |
![]() | PostAsync(Uri, HttpContent, CancellationToken) | Sends a POST request with a cancellation token as an asynchronous operation. |
![]() | PutAsync(String, HttpContent) | Sends a PUT request to the specified Uri as an asynchronous operation. |
![]() | PutAsync(Uri, HttpContent) | Sends a PUT request to the specified Uri as an asynchronous operation. |
![]() | PutAsync(String, HttpContent, CancellationToken) | Sends a PUT request with a cancellation token as an asynchronous operation. |
![]() | PutAsync(Uri, HttpContent, CancellationToken) | Sends a PUT request with a cancellation token as an asynchronous operation. |
![]() | SendAsync(HttpRequestMessage) | Sends an HTTP request as an asynchronous operation. |
![]() | SendAsync(HttpRequestMessage, HttpCompletionOption) | Sends an HTTP request with an HTTP completion option as an asynchronous operation. |
![]() | SendAsync(HttpRequestMessage, CancellationToken) | Sends an HTTP request with a cancellation token as an asynchronous operation. (Overrides HttpMessageInvoker::SendAsync(HttpRequestMessage, CancellationToken).) |
![]() | SendAsync(HttpRequestMessage, HttpCompletionOption, CancellationToken) | Sends an HTTP request with an HTTP completion option and cancellation token as an asynchronous operation. |
![]() | ToString | (Inherited from Object.) |
For a complete example of using the HttpClient class, see Calling a Web API From a .NET Client
Show:


