WinHttpHandler WinHttpHandler WinHttpHandler WinHttpHandler Class

定義

WinHttpHandler 是以 Windows 的 WinHTTP 介面為基礎的特殊訊息處理常式,預定在伺服器環境中使用。WinHttpHandler is a specialty message handler based on the WinHTTP interface of Windows and is intended for use in server environments. 透過將這個類別安裝為 NuGet 封裝,其也可用於桌面應用程式。This class is also available for use in Desktop apps by installing it as a NuGet package. 如需安裝這個類別以用於桌面應用程式的詳細資訊,請參閱 System.Net.Http.WinHttpHandlerFor 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
繼承

備註

WinHttpHandler 是類似於其他現有的類別,例如HttpClientHandlerWinHttpHandler is similar to other existing classes such as HttpClientHandler. WinHttpHandler 提供的處理常式下方HttpClient執行個體,並使用 HTTP 要求傳送給伺服器,並接收伺服器回應。WinHttpHandler provides a handler underneath an HttpClient instance and is used to send HTTP requests out to a server and receive server responses.

WinHttpHandler 可由 ASP.NET Core 和其他與 HTTP 伺服器溝通的.NET 應用程式,主要是在伺服器環境中使用。WinHttpHandler is designed to be used primarily in server environments by ASP.NET Core and other .NET applications that communicate with HTTP servers. WinHttpHandler 也為開發人員提供更細微地控制應用程式的 HTTP 通訊,比HttpClientHandler類別。WinHttpHandler also provides developers with more granular control over the application's HTTP communication than the HttpClientHandler class. 這可讓開發人員實作更進階的 HTTP 狀況,或修改系統預設值 (例如,proxy 設定,逾時和伺服器 SSL 憑證驗證)。This allows developers to implement more advanced HTTP scenarios or modify system defaults (for example, proxy settings, timeouts and server SSL certificate validation).

WinHttpHandler 不是要來取代HttpClientHandler,這是更進階的版本提供案例的其中HttpClientHandler並不足以開發人員。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 會實作為 Windows 的 WinHTTP 介面的精簡型包裝函式,並僅適用於 Windows 系統上。WinHttpHandler is implemented as a thin wrapper on the WinHTTP interface of Windows and is only supported on Windows systems.

當使用一連串的多個處理常式,WinHttpHandler應鏈結的底部。When using a chain of multiple handlers, WinHttpHandler should be at the bottom of the chain.

建構函式

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

初始化 WinHttpHandler 類別的新執行個體。Initializes a new instance of the WinHttpHandler class.

屬性

AutomaticDecompression AutomaticDecompression AutomaticDecompression AutomaticDecompression

取得或設定解壓縮方法的類型,此為 HTTP 內容回應的自動解壓縮處理常式所使用。Gets or sets the type of decompression method used by the handler for automatic decompression of the HTTP content response.

AutomaticRedirection AutomaticRedirection AutomaticRedirection AutomaticRedirection

取得或設定值,指出此處理常式是否應該接在 HTTP 重新導向回應之後。Gets or sets a value that indicates whether the handler should follow HTTP redirection responses.

CheckCertificateRevocationList CheckCertificateRevocationList CheckCertificateRevocationList CheckCertificateRevocationList

取得或設定值,指出在 SSL 憑證驗證期間是否要檢查憑證撤銷清單。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

如果 ClientCertificateOption 屬性設定為 Manual,請取得或設定處理常式用於用戶端驗證之用戶端驗證 SSL 憑證的集合。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

取得或設定受管理的 Cookie 容器物件。Gets or sets the managed cookie container object. 只有當 CookieUsePolicy 屬性設定為 UseSpecifiedCookieContainer 時,才使用這個屬性。This property is only used when the CookieUsePolicy property is set to UseSpecifiedCookieContainer. 否則,SendAsync(HttpRequestMessage, CancellationToken) 方法將擲回例外狀況。Otherwise, the SendAsync(HttpRequestMessage, CancellationToken) method will throw an exception.

CookieUsePolicy CookieUsePolicy CookieUsePolicy CookieUsePolicy

取得或設定值,指出應如何管理和使用 Cookie。Gets or sets a value that indicates how cookies should be managed and used. 開發人員可以選擇忽略 Cookie、允許處理常式自動管理 Cookie,或使用 CookieContainer 物件以手動方式處理 Cookie。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

取得或設定用來向驗證 Proxy 驗證使用者的認證。Gets or sets the credentials used to authenticate the user to an authenticating proxy.

MaxAutomaticRedirections MaxAutomaticRedirections MaxAutomaticRedirections MaxAutomaticRedirections

取得或設定允許的 HTTP 重新導向的數目上限。Gets or sets the maximum number of allowed HTTP redirects.

MaxConnectionsPerServer MaxConnectionsPerServer MaxConnectionsPerServer MaxConnectionsPerServer

取得或設定單一伺服器所允許的 TCP 連線數目上限。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

取得或設定當 WindowsProxyUsePolicy 屬性設定為使用自訂 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. 此回呼是 SSL 信號交換的一部分。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

取得或設定用戶端所支援的 TLS/SSL 通訊協定的集合。Gets or sets the collection of TLS/SSL protocols supported by the client.

WindowsProxyUsePolicy WindowsProxyUsePolicy WindowsProxyUsePolicy WindowsProxyUsePolicy

取得或設定 Proxy 設定。Gets or sets the proxy setting. 這個屬性可以設定為停用 Proxy、使用自訂 Proxy,或是使用電腦上 WinHTTP 或 WinInet 的 Proxy 設定。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.

方法

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

釋放 Unmanaged 資源,並處置 HttpMessageHandler 所使用的 Managed 資源。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()

取得目前執行個體的 TypeGets the Type of the current instance.

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

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

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

以非同步作業的方式傳送 HTTP 要求。Sends an HTTP request as an asynchronous operation.

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

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於