HttpClientBuilderExtensions.UseSocketsHttpHandler 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
UseSocketsHttpHandler(IHttpClientBuilder, Action<ISocketsHttpHandlerBuilder>) |
新增或更新 SocketsHttpHandler 作為具名 HttpClient 的主要處理程式,並使用 加以 ISocketsHttpHandlerBuilder設定。 |
UseSocketsHttpHandler(IHttpClientBuilder, Action<SocketsHttpHandler,IServiceProvider>) |
將或更新 SocketsHttpHandler 新增為具名 HttpClient的主要處理程式。 如果提供,也新增將用來設定主要 SocketsHttpHandler的委派。 |
UseSocketsHttpHandler(IHttpClientBuilder, Action<ISocketsHttpHandlerBuilder>)
新增或更新 SocketsHttpHandler 作為具名 HttpClient 的主要處理程式,並使用 加以 ISocketsHttpHandlerBuilder設定。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ UseSocketsHttpHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Action<Microsoft::Extensions::DependencyInjection::ISocketsHttpHandlerBuilder ^> ^ configureBuilder);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder UseSocketsHttpHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Action<Microsoft.Extensions.DependencyInjection.ISocketsHttpHandlerBuilder> configureBuilder);
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member UseSocketsHttpHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Action<Microsoft.Extensions.DependencyInjection.ISocketsHttpHandlerBuilder> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function UseSocketsHttpHandler (builder As IHttpClientBuilder, configureBuilder As Action(Of ISocketsHttpHandlerBuilder)) As IHttpClientBuilder
參數
- builder
- IHttpClientBuilder
- configureBuilder
- Action<ISocketsHttpHandlerBuilder>
委派,用來設定主要處理程式的組態SocketsHttpHandlerISocketsHttpHandlerBuilder,稍後將在建立期間套用至主要處理程式。
傳回
可以用於設定用戶端的 IHttpClientBuilder。
- 屬性
備註
如果先前呼叫 或 UseSocketsHttpHandler(IHttpClientBuilder, Action<ISocketsHttpHandlerBuilder>)之前已將主要處理程式設定為 SocketsHttpHandler ,ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>)則 上的ISocketsHttpHandlerBuilder組態集將會套用至現有的實例。 否則,將會建立的新實例 SocketsHttpHandler 。
適用於
UseSocketsHttpHandler(IHttpClientBuilder, Action<SocketsHttpHandler,IServiceProvider>)
將或更新 SocketsHttpHandler 新增為具名 HttpClient的主要處理程式。 如果提供,也新增將用來設定主要 SocketsHttpHandler的委派。
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder UseSocketsHttpHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Action<System.Net.Http.SocketsHttpHandler,IServiceProvider>? configureHandler = default);
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member UseSocketsHttpHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Action<System.Net.Http.SocketsHttpHandler, IServiceProvider> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function UseSocketsHttpHandler (builder As IHttpClientBuilder, Optional configureHandler As Action(Of SocketsHttpHandler, IServiceProvider) = Nothing) As IHttpClientBuilder
參數
- builder
- IHttpClientBuilder
- configureHandler
- Action<SocketsHttpHandler,IServiceProvider>
用來設定主要 SocketsHttpHandler的選擇性委派。
傳回
可以用於設定用戶端的 IHttpClientBuilder。
- 屬性
備註
如果先前呼叫 或 UseSocketsHttpHandler(IHttpClientBuilder, Action<ISocketsHttpHandlerBuilder>)之前已將主要處理程式設定為 SocketsHttpHandler ,ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>)則傳遞的configureHandler
委派會套用至現有的實例。 否則,將會建立的新實例 SocketsHttpHandler 。