HttpClientBuilderExtensions.AddHttpMessageHandler 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>) |
新增將用於為具名 HttpClient 建立其他訊息處理常式的委派。 |
AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>) |
新增將用於為具名 HttpClient 建立其他訊息處理常式的委派。 |
AddHttpMessageHandler<THandler>(IHttpClientBuilder) |
從具名 HttpClient 的相依性插入容器中,新增額外的訊息處理常式。 |
AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>)
新增將用於為具名 HttpClient 建立其他訊息處理常式的委派。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<IServiceProvider ^, System::Net::Http::DelegatingHandler ^> ^ configureHandler);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpMessageHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<IServiceProvider,System.Net.Http.DelegatingHandler> configureHandler);
static member AddHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<IServiceProvider, System.Net.Http.DelegatingHandler> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function AddHttpMessageHandler (builder As IHttpClientBuilder, configureHandler As Func(Of IServiceProvider, DelegatingHandler)) As IHttpClientBuilder
參數
- builder
- IHttpClientBuilder
- configureHandler
- Func<IServiceProvider,DelegatingHandler>
用於建立 DelegatingHandler 的委派。
傳回
可以用於設定用戶端的 IHttpClientBuilder。
備註
委派 configureHandler
應該會在每次叫用訊息處理程式時傳回新的實例。
提供給 configureHandler
的IServiceProvider自變數將會是範圍服務提供者的參考,可共用所要建構之處理程式的存留期。
適用於
AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>)
新增將用於為具名 HttpClient 建立其他訊息處理常式的委派。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<System::Net::Http::DelegatingHandler ^> ^ configureHandler);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpMessageHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<System.Net.Http.DelegatingHandler> configureHandler);
static member AddHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<System.Net.Http.DelegatingHandler> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function AddHttpMessageHandler (builder As IHttpClientBuilder, configureHandler As Func(Of DelegatingHandler)) As IHttpClientBuilder
參數
- builder
- IHttpClientBuilder
- configureHandler
- Func<DelegatingHandler>
用於建立 DelegatingHandler 的委派。
傳回
可以用於設定用戶端的 IHttpClientBuilder。
備註
委派 configureHandler
應該會在每次叫用訊息處理程式時傳回新的實例。
適用於
AddHttpMessageHandler<THandler>(IHttpClientBuilder)
從具名 HttpClient 的相依性插入容器中,新增額外的訊息處理常式。
public:
generic <typename THandler>
where THandler : System::Net::Http::DelegatingHandler[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddHttpMessageHandler<THandler> (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder) where THandler : System.Net.Http.DelegatingHandler;
static member AddHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Handler :> System.Net.Http.DelegatingHandler)
<Extension()>
Public Function AddHttpMessageHandler(Of THandler As DelegatingHandler) (builder As IHttpClientBuilder) As IHttpClientBuilder
類型參數
- THandler
DelegatingHandler 的類型。 處理程式類型必須註冊為暫時性服務。
參數
- builder
- IHttpClientBuilder
傳回
可以用於設定用戶端的 IHttpClientBuilder。
備註
THandler
將會從共用所建構處理程式存留期的範圍服務提供者解析。