HttpClientBuilderExtensions.AddHttpMessageHandler Method

Definition

Overloads

AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>)

Adds a delegate that will be used to create an additional message handler for a named HttpClient.

AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>)

Adds a delegate that will be used to create an additional message handler for a named HttpClient.

AddHttpMessageHandler<THandler>(IHttpClientBuilder)

Adds an additional message handler from the dependency injection container for a named HttpClient.

AddHttpMessageHandler(IHttpClientBuilder, Func<IServiceProvider,DelegatingHandler>)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

Adds a delegate that will be used to create an additional message handler for a named 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

Parameters

configureHandler
Func<IServiceProvider,DelegatingHandler>

A delegate that is used to create a DelegatingHandler.

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

AddHttpMessageHandler(IHttpClientBuilder, Func<DelegatingHandler>)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

Adds a delegate that will be used to create an additional message handler for a named 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

Parameters

configureHandler
Func<DelegatingHandler>

A delegate that is used to create a DelegatingHandler.

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

AddHttpMessageHandler<THandler>(IHttpClientBuilder)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

Adds an additional message handler from the dependency injection container for a named 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

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