Kongsi melalui


HttpClientBuilderExtensions.ConfigurePrimaryHttpMessageHandler Method

Definition

Overloads

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Action<HttpMessageHandler,IServiceProvider>)

Adds a delegate that will be used to configure the primary HttpMessageHandler for a named HttpClient.

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,HttpMessageHandler>)

Adds a delegate that will be used to configure the primary HttpMessageHandler for a named HttpClient.

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>)

Adds a delegate that will be used to configure the primary HttpMessageHandler for a named HttpClient.

ConfigurePrimaryHttpMessageHandler<THandler>(IHttpClientBuilder)

Configures the primary HttpMessageHandler from the dependency injection container for a named HttpClient.

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Action<HttpMessageHandler,IServiceProvider>)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

Adds a delegate that will be used to configure the primary HttpMessageHandler for a named HttpClient.

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

Parameters

configureHandler
Action<HttpMessageHandler,IServiceProvider>

A delegate that is used to configure a previously set or default primary HttpMessageHandler.

Returns

An IHttpClientBuilder that can be used to configure the client.

Remarks

The IServiceProvider argument provided to configureHandler will be a reference to a scoped service provider that shares the lifetime of the handler being constructed.

Applies to

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,HttpMessageHandler>)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

Adds a delegate that will be used to configure the primary HttpMessageHandler for a named HttpClient.

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

Parameters

configureHandler
Func<IServiceProvider,HttpMessageHandler>

A delegate that is used to create an HttpMessageHandler.

Returns

An IHttpClientBuilder that can be used to configure the client.

Remarks

The configureHandler delegate should return a new instance of the message handler each time it is invoked.

The IServiceProvider argument provided to configureHandler will be a reference to a scoped service provider that shares the lifetime of the handler being constructed.

Applies to

ConfigurePrimaryHttpMessageHandler(IHttpClientBuilder, Func<HttpMessageHandler>)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

Adds a delegate that will be used to configure the primary HttpMessageHandler for a named HttpClient.

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

Parameters

configureHandler
Func<HttpMessageHandler>

A delegate that is used to create an HttpMessageHandler.

Returns

An IHttpClientBuilder that can be used to configure the client.

Remarks

The configureHandler delegate should return a new instance of the message handler each time it is invoked.

Applies to

ConfigurePrimaryHttpMessageHandler<THandler>(IHttpClientBuilder)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

Configures the primary HttpMessageHandler from the dependency injection container for a named HttpClient.

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

Type Parameters

THandler

The type of the DelegatingHandler. The handler type must be registered as a transient service.

Parameters

Returns

An IHttpClientBuilder that can be used to configure the client.

Remarks

The THandler will be resolved from a scoped service provider that shares the lifetime of the handler being constructed.

Applies to