共用方式為


HttpClientBuilderExtensions.AddHttpMessageHandler 方法

定義

多載

AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>)

新增將用於為具名 HttpClient 建立其他訊息處理常式的委派。

AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>)

新增將用於為具名 HttpClient 建立其他訊息處理常式的委派。

AddHttpMessageHandler<THandler>(IHttpClientBuilder)

從具名 HttpClient 的相依性插入容器中,新增額外的訊息處理常式。

AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>)

來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs

新增將用於為具名 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

參數

configureHandler
Func<IServiceProvider,DelegatingHandler>

用於建立 DelegatingHandler 的委派。

傳回

可以用於設定用戶端的 IHttpClientBuilder

備註

委派 configureHandler 應該會在每次叫用訊息處理程式時傳回新的實例。

提供給 configureHandlerIServiceProvider自變數將會是範圍服務提供者的參考,可共用所要建構之處理程式的存留期。

適用於

AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>)

來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs

新增將用於為具名 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

參數

configureHandler
Func<DelegatingHandler>

用於建立 DelegatingHandler 的委派。

傳回

可以用於設定用戶端的 IHttpClientBuilder

備註

委派 configureHandler 應該會在每次叫用訊息處理程式時傳回新的實例。

適用於

AddHttpMessageHandler<THandler>(IHttpClientBuilder)

來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs

從具名 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 的類型。 處理程式類型必須註冊為暫時性服務。

參數

傳回

可以用於設定用戶端的 IHttpClientBuilder

備註

THandler將會從共用所建構處理程式存留期的範圍服務提供者解析。

適用於