HttpClientBuilderExtensions.ConfigureHttpClient Method

Definition

Overloads

ConfigureHttpClient(IHttpClientBuilder, Action<HttpClient>)

Adds a delegate that will be used to configure a named HttpClient.

ConfigureHttpClient(IHttpClientBuilder, Action<IServiceProvider,HttpClient>)

Adds a delegate that will be used to configure a named HttpClient.

ConfigureHttpClient(IHttpClientBuilder, Action<HttpClient>)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

Adds a delegate that will be used to configure a named HttpClient.

C#
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder ConfigureHttpClient(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Action<System.Net.Http.HttpClient> configureClient);

Parameters

configureClient
Action<HttpClient>

A delegate that is used to configure an HttpClient.

Returns

An IHttpClientBuilder that can be used to configure the client.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

ConfigureHttpClient(IHttpClientBuilder, Action<IServiceProvider,HttpClient>)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

Adds a delegate that will be used to configure a named HttpClient.

C#
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder ConfigureHttpClient(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Action<IServiceProvider,System.Net.Http.HttpClient> configureClient);

Parameters

configureClient
Action<IServiceProvider,HttpClient>

A delegate that is used to configure an HttpClient.

Returns

An IHttpClientBuilder that can be used to configure the client.

Remarks

The IServiceProvider provided to configureClient will be the same application's root service provider instance.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)