共用方式為


HttpClientBuilderExtensions.ConfigurePrimaryHttpMessageHandler 方法

定義

多載

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Action<HttpMessageHandler,IServiceProvider>)

新增將用來設定具名 HttpClient 之主要 HttpMessageHandler 的委派。

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,HttpMessageHandler>)

新增將用來設定具名 HttpClient 之主要 HttpMessageHandler 的委派。

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>)

新增將用來設定具名 HttpClient 之主要 HttpMessageHandler 的委派。

ConfigurePrimaryHttpMessageHandler<THandler>(IHttpClientBuilder)

從具名 HttpClient 的相依性插入容器中設定主要 HttpMessageHandler

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Action<HttpMessageHandler,IServiceProvider>)

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

新增將用來設定具名 HttpClient 之主要 HttpMessageHandler 的委派。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ ConfigurePrimaryHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Action<System::Net::Http::HttpMessageHandler ^, IServiceProvider ^> ^ configureHandler);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder ConfigurePrimaryHttpMessageHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Action<System.Net.Http.HttpMessageHandler,IServiceProvider> configureHandler);
static member ConfigurePrimaryHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Action<System.Net.Http.HttpMessageHandler, IServiceProvider> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function ConfigurePrimaryHttpMessageHandler (builder As IHttpClientBuilder, configureHandler As Action(Of HttpMessageHandler, IServiceProvider)) As IHttpClientBuilder

參數

configureHandler
Action<HttpMessageHandler,IServiceProvider>

用來設定先前設定或預設主要 的 HttpMessageHandler委派。

傳回

可以用於設定用戶端的 IHttpClientBuilder

備註

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

適用於

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,HttpMessageHandler>)

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

新增將用來設定具名 HttpClient 之主要 HttpMessageHandler 的委派。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ ConfigurePrimaryHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<IServiceProvider ^, System::Net::Http::HttpMessageHandler ^> ^ configureHandler);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder ConfigurePrimaryHttpMessageHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<IServiceProvider,System.Net.Http.HttpMessageHandler> configureHandler);
static member ConfigurePrimaryHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<IServiceProvider, System.Net.Http.HttpMessageHandler> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function ConfigurePrimaryHttpMessageHandler (builder As IHttpClientBuilder, configureHandler As Func(Of IServiceProvider, HttpMessageHandler)) As IHttpClientBuilder

參數

configureHandler
Func<IServiceProvider,HttpMessageHandler>

用於建立 HttpMessageHandler 的委派。

傳回

可以用於設定用戶端的 IHttpClientBuilder

備註

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

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

適用於

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>)

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

新增將用來設定具名 HttpClient 之主要 HttpMessageHandler 的委派。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ ConfigurePrimaryHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<System::Net::Http::HttpMessageHandler ^> ^ configureHandler);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder ConfigurePrimaryHttpMessageHandler (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<System.Net.Http.HttpMessageHandler> configureHandler);
static member ConfigurePrimaryHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<System.Net.Http.HttpMessageHandler> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder
<Extension()>
Public Function ConfigurePrimaryHttpMessageHandler (builder As IHttpClientBuilder, configureHandler As Func(Of HttpMessageHandler)) As IHttpClientBuilder

參數

configureHandler
Func<HttpMessageHandler>

用於建立 HttpMessageHandler 的委派。

傳回

可以用於設定用戶端的 IHttpClientBuilder

備註

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

適用於

ConfigurePrimaryHttpMessageHandler<THandler>(IHttpClientBuilder)

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

從具名 HttpClient 的相依性插入容器中設定主要 HttpMessageHandler

public:
generic <typename THandler>
 where THandler : System::Net::Http::HttpMessageHandler[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ ConfigurePrimaryHttpMessageHandler(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder ConfigurePrimaryHttpMessageHandler<THandler> (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder) where THandler : System.Net.Http.HttpMessageHandler;
static member ConfigurePrimaryHttpMessageHandler : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Handler :> System.Net.Http.HttpMessageHandler)
<Extension()>
Public Function ConfigurePrimaryHttpMessageHandler(Of THandler As HttpMessageHandler) (builder As IHttpClientBuilder) As IHttpClientBuilder

類型參數

THandler

DelegatingHandler 的類型。 處理程式類型必須註冊為暫時性服務。

參數

傳回

可以用於設定用戶端的 IHttpClientBuilder

備註

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

適用於