WinHttpHandler WinHttpHandler WinHttpHandler WinHttpHandler Class

Definition

WinHttpHandler is a specialty message handler based on the WinHTTP interface of Windows and is intended for use in server environments. This class is also available for use in Desktop apps by installing it as a NuGet package. For more information about installing this class for use in Desktop apps, see System.Net.Http.WinHttpHandler.

public ref class WinHttpHandler : System::Net::Http::HttpMessageHandler
public class WinHttpHandler : System.Net.Http.HttpMessageHandler
type WinHttpHandler = class
    inherit HttpMessageHandler
Public Class WinHttpHandler
Inherits HttpMessageHandler
Inheritance

Remarks

WinHttpHandler is similar to other existing classes such as HttpClientHandler. WinHttpHandler provides a handler underneath an HttpClient instance and is used to send HTTP requests out to a server and receive server responses.

WinHttpHandler is designed to be used primarily in server environments by ASP.NET Core and other .NET applications that communicate with HTTP servers. WinHttpHandler also provides developers with more granular control over the application's HTTP communication than the HttpClientHandler class. This allows developers to implement more advanced HTTP scenarios or modify system defaults (for example, proxy settings, timeouts and server SSL certificate validation).

WinHttpHandler is not intended to be a replacement for HttpClientHandler, it is a more advanced version provided for scenarios where HttpClientHandler is insufficient for developers. WinHttpHandler is implemented as a thin wrapper on the WinHTTP interface of Windows and is only supported on Windows systems.

When using a chain of multiple handlers, WinHttpHandler should be at the bottom of the chain.

Constructors

WinHttpHandler() WinHttpHandler() WinHttpHandler() WinHttpHandler()

Initializes a new instance of the WinHttpHandler class.

Properties

AutomaticDecompression AutomaticDecompression AutomaticDecompression AutomaticDecompression

Gets or sets the type of decompression method used by the handler for automatic decompression of the HTTP content response.

AutomaticRedirection AutomaticRedirection AutomaticRedirection AutomaticRedirection

Gets or sets a value that indicates whether the handler should follow HTTP redirection responses.

CheckCertificateRevocationList CheckCertificateRevocationList CheckCertificateRevocationList CheckCertificateRevocationList

Gets or sets a value that indicates whether to check the revocation list of certificates during SSL certificate validation.

ClientCertificateOption ClientCertificateOption ClientCertificateOption ClientCertificateOption

Gets or sets a value that indicates if the certificate is automatically picked from the certificate store or if the caller is allowed to pass in a specific client certificate.

ClientCertificates ClientCertificates ClientCertificates ClientCertificates

Gets or sets a collection of client authentication SSL certificates that are used for client authentication by the Handler if the ClientCertificateOption property is set to Manual.

CookieContainer CookieContainer CookieContainer CookieContainer

Gets or sets the managed cookie container object. This property is only used when the CookieUsePolicy property is set to UseSpecifiedCookieContainer. Otherwise, the SendAsync(HttpRequestMessage, CancellationToken) method will throw an exception.

CookieUsePolicy CookieUsePolicy CookieUsePolicy CookieUsePolicy

Gets or sets a value that indicates how cookies should be managed and used. Developers can choose to ignore cookies, allow the handler to automatically manage them or manually handle them using a CookieContainer object.

DefaultProxyCredentials DefaultProxyCredentials DefaultProxyCredentials DefaultProxyCredentials

Gets or sets the credentials used to authenticate the user to an authenticating proxy.

MaxAutomaticRedirections MaxAutomaticRedirections MaxAutomaticRedirections MaxAutomaticRedirections

Gets or sets the maximum number of allowed HTTP redirects.

MaxConnectionsPerServer MaxConnectionsPerServer MaxConnectionsPerServer MaxConnectionsPerServer

Gets or sets the maximum number of TCP connections allowed to a single server.

MaxResponseDrainSize MaxResponseDrainSize MaxResponseDrainSize MaxResponseDrainSize

Gets or sets the maximum amount of data that can be drained from responses in bytes.

MaxResponseHeadersLength MaxResponseHeadersLength MaxResponseHeadersLength MaxResponseHeadersLength

Gets or sets the maximum size of the header portion from the server response in bytes.

PreAuthenticate PreAuthenticate PreAuthenticate PreAuthenticate

Gets or sets a value that indicates whether the handler sends an Authorization header with the request.

Properties Properties Properties Properties
Proxy Proxy Proxy Proxy

Gets or sets the custom proxy when the WindowsProxyUsePolicy property is set to use a custom proxy.

ReceiveDataTimeout ReceiveDataTimeout ReceiveDataTimeout ReceiveDataTimeout

Gets or sets the timeout for receiving the data portion of a response from the server.

ReceiveHeadersTimeout ReceiveHeadersTimeout ReceiveHeadersTimeout ReceiveHeadersTimeout

Gets or sets the timeout for receiving the headers of a response from the server.

SendTimeout SendTimeout SendTimeout SendTimeout

Gets or sets the timeout for sending a request.

ServerCertificateValidationCallback ServerCertificateValidationCallback ServerCertificateValidationCallback ServerCertificateValidationCallback

Gets or sets a callback method to validate the server certificate. This callback is part of the SSL handshake.

ServerCredentials ServerCredentials ServerCredentials ServerCredentials

Gets or sets the credentials to be used by the client to authenticate to the server.

SslProtocols SslProtocols SslProtocols SslProtocols

Gets or sets the collection of TLS/SSL protocols supported by the client.

WindowsProxyUsePolicy WindowsProxyUsePolicy WindowsProxyUsePolicy WindowsProxyUsePolicy

Gets or sets the proxy setting. This property can be set to disable the proxy, use a custom proxy, or use the proxy settings of WinHTTP or WinInet on the machine.

Methods

Dispose() Dispose() Dispose() Dispose()

Releases the unmanaged resources and disposes of the managed resources used by the HttpMessageHandler.

(Inherited from HttpMessageHandler)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SendAsync(HttpRequestMessage, CancellationToken) SendAsync(HttpRequestMessage, CancellationToken) SendAsync(HttpRequestMessage, CancellationToken) SendAsync(HttpRequestMessage, CancellationToken)

Sends an HTTP request as an asynchronous operation.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to