HttpClientHandler Class
.NET Framework 4.5
The default message handler used by HttpClient.
System.Object
System.Net.Http.HttpMessageHandler
System.Net.Http.HttpClientHandler
System.Net.Http.WebRequestHandler
System.Net.Http.HttpMessageHandler
System.Net.Http.HttpClientHandler
System.Net.Http.WebRequestHandler
Namespace: System.Net.Http
Assembly: System.Net.Http (in System.Net.Http.dll)
The HttpClientHandler type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() | AllowAutoRedirect | Gets or sets a value that indicates whether the handler should follow redirection responses. |
![]() ![]() | AutomaticDecompression | Gets or sets the type of decompression method used by the handler for automatic decompression of the HTTP content response. |
![]() ![]() | ClientCertificateOptions | Gets or sets the collection of security certificates that are associated with this handler. |
![]() ![]() | CookieContainer | Gets or sets the cookie container used to store server cookies by the handler. |
![]() ![]() | Credentials | Gets or sets authentication information used by this handler. |
![]() ![]() | MaxAutomaticRedirections | Gets or sets the maximum number of redirects that the handler follows. |
![]() ![]() | MaxRequestContentBufferSize | Gets or sets the maximum request content buffer size used by the handler. |
![]() ![]() | PreAuthenticate | Gets or sets a value that indicates whether the handler sends an Authorization header with the request. |
![]() ![]() | Proxy | Gets or sets proxy information used by the handler. |
![]() ![]() | SupportsAutomaticDecompression | Gets a value that indicates whether the handler supports automatic response content decompression. |
![]() ![]() | SupportsProxy | Gets a value that indicates whether the handler supports proxy settings. |
![]() ![]() | SupportsRedirectConfiguration | Gets a value that indicates whether the handler supports configuration settings for the AllowAutoRedirect and MaxAutomaticRedirections properties. |
![]() ![]() | UseCookies | Gets or sets a value that indicates whether the handler uses the CookieContainer property to store server cookies and uses these cookies when sending requests. |
![]() ![]() | UseDefaultCredentials | Gets or sets a value that controls whether default credentials are sent with requests by the handler. |
![]() ![]() | UseProxy | Gets or sets a value that indicates whether the handler uses a proxy for requests. |
| Name | Description | |
|---|---|---|
![]() ![]() | Dispose() | Releases the unmanaged resources and disposes of the managed resources used by the HttpMessageHandler. (Inherited from HttpMessageHandler.) |
![]() ![]() | Dispose(Boolean) | Releases the unmanaged resources used by the HttpClientHandler and optionally disposes of the managed resources. (Overrides HttpMessageHandler.Dispose(Boolean).) |
![]() ![]() | Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() ![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() ![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() ![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() ![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() ![]() | SendAsync | Creates an instance of HttpResponseMessage based on the information provided in the HttpRequestMessage as an operation that will not block. (Overrides HttpMessageHandler.SendAsync(HttpRequestMessage, CancellationToken).) |
![]() ![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
static async void Main() { try { HttpClientHandler handler = new HttpClientHandler(); handler.UseDefaultCredentials = true; // Create a New HttpClient object. HttpClient client = new HttpClient(handler); HttpResponseMessage response = await client.GetAsync("http://www.contoso.com/"); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } catch(HttpRequestException e) { Console.WriteLine("\nException Caught!"); Console.WriteLine("Message :{0} ",e.Message); } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.



