Microsoft.Extensions.Http 9.0.11

About

Microsoft.Extensions.Http package provides AddHttpClient extension methods for IServiceCollection, IHttpClientFactory interface and its default implementation. This provides the ability to set up named HttpClient configurations in a DI container and later retrieve them via an injected IHttpClientFactory instance.

Key Features

  • The package allows to fluently set up multiple HttpClient configurations for applications that use DI via AddHttpClient extension method.
  • HttpClientFactory caches HttpMessageHandler instances per configuration name, which allows to reuse resources between HttpClient instances to avoid port exhaustion.
  • HttpClientFactory manages lifetime of HttpMessageHandler instances and recycles connections to track DNS changes.

How to Use

Note that lifetime management of HttpClient instances created by HttpClientFactory is completely different from instances created manually. The strategies are to use either short-lived clients created by HttpClientFactory or long-lived clients with PooledConnectionLifetime set up. For more information, see the HttpClient lifetime management section in the conceptual docs and Guidelines for using HTTP clients.

Configuring HttpClient

builder.Services.AddHttpClient("foo"); // adding an HttpClient named "foo" with a default configuration

builder.Services.AddHttpClient("example", c => c.BaseAddress = new Uri("https://www.example.com")) // configuring HttpClient itself
    .AddHttpMessageHandler<MyAuthHandler>() // adding additional delegating handlers to form a message handler chain
    .ConfigurePrimaryHttpMessageHandler(b => new HttpClientHandler() { AllowAutoRedirect = false }) // configuring primary handler
    .SetHandlerLifetime(TimeSpan.FromMinutes(30)); // changing the handler recycling interval

Using the configured HttpClient

public class MyService
{
    public MyService(IHttpClientFactory httpClientFactory)
    {
        _httpClientFactory = httpClientFactory; // injecting the factory
    }

    private Task<string> GetExampleAsync(Uri uri, CancellationToken ct)
    {
        HttpClient exampleClient = _httpClientFactory.CreateClient("example"); // creating the client for the specified name
        return exampleClient.GetStringAsync(uri, ct); // using the client
    }
}

Main Types

The main types provided by this library are:

  • IHttpClientFactory
  • IHttpMessageHandlerFactory
  • HttpClientFactoryServiceCollectionExtensions

Additional Documentation

Feedback & Contributing

Microsoft.Extensions.Http is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on Microsoft.Extensions.Http.

Packages Downloads
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/1f49b6637a0c3a6af34b42332e06966e4d383d54
11
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/331b52b370cd4e7fe2919d4d4cda27412e2ab1cc
11
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/67e04394e98d5bfa6a5684d471a72fcbe30fd587
11
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/8ca3954ca335343ce6dd1d14d8d1c6c3369710b7
12
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/b908e913e3befcfe241f3294509e6d9570acc07b
11
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/c04846dc66cc97f71d83a83a15437828435f5d44
11
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/32e8c8cae5b1a4dd752d0a42a6f8a2813f75f173
12
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/3b519aa7d1a1b66e1d329d694f814e1d8228dc8c
12
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/417d650029c720dbd2138bcafbb78e2e4ff31bff
13
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/55738ff96b832439076e25584cfe0eb3bace9b01
11
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/57512b49997283599b00a6b67d0ccebaec171daf
12
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/64ea4108e7dcf1ca575f8dd2028363b0b1ef6ebc
11
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/be51b1aa73343e45a1d00afd436abad794f471fb
11
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/cec88a329584349fda070f4c7346b10538210ace
12
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/d827c653b787c07de908240b7746ce34d3e6271e
12
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/e882394a7bb38930da748291fe2c2ceaa6a80588
11
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/f0f9de5692adf1c0576de062f93c6ab7b176433f
12
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/fb4b5a21ebd67b31fff4ddf5c039181da504c932
11
Microsoft.AspNetCore.ApiAuthorization.IdentityServer
ASP.NET Core API Authorization package powered by Identity Server. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/fc93e595ceffbb1e3e85532bf454e92a6a80dd6b
11
reCAPTCHA.Net
Google reCAPTCHA .NET Standard 2.0
16

Version Downloads Last updated
10.0.1 0 09.12.2025
10.0.0 3 20.11.2025
10.0.0-rc.2.25502.107 3 30.11.2025
10.0.0-rc.1.25451.107 2 28.11.2025
10.0.0-preview.7.25380.108 2 21.08.2025
10.0.0-preview.6.25358.103 3 06.08.2025
10.0.0-preview.5.25277.114 7 08.06.2025
10.0.0-preview.4.25258.110 8 23.05.2025
10.0.0-preview.3.25171.5 7 24.05.2025
10.0.0-preview.2.25163.2 7 21.03.2025
10.0.0-preview.1.25080.5 8 13.03.2025
9.0.11 2 22.11.2025
9.0.10 0 14.10.2025
9.0.9 5 16.09.2025
9.0.8 6 21.08.2025
9.0.7 5 06.08.2025
9.0.6 11 16.06.2025
9.0.5 13 23.05.2025
9.0.4 13 23.05.2025
9.0.3 11 12.03.2025
9.0.2 11 12.03.2025
9.0.1 13 23.01.2025
9.0.0 11 23.01.2025
9.0.0-rc.2.24473.5 7 23.01.2025
9.0.0-rc.1.24431.7 7 30.01.2025
9.0.0-preview.7.24405.7 10 23.01.2025
9.0.0-preview.6.24327.7 6 23.01.2025
9.0.0-preview.5.24306.7 7 29.01.2025
9.0.0-preview.4.24266.19 7 23.01.2025
9.0.0-preview.3.24172.9 11 23.01.2025
9.0.0-preview.2.24128.5 7 29.01.2025
9.0.0-preview.1.24080.9 6 23.01.2025
8.0.1 10 29.01.2025
8.0.0 13 23.01.2025
8.0.0-rc.2.23479.6 7 29.01.2025
8.0.0-rc.1.23419.4 7 30.01.2025
8.0.0-preview.7.23375.6 8 23.01.2025
8.0.0-preview.6.23329.7 6 24.01.2025
8.0.0-preview.5.23280.8 7 31.01.2025
8.0.0-preview.4.23259.5 6 29.01.2025
8.0.0-preview.3.23174.8 7 24.01.2025
8.0.0-preview.2.23128.3 7 28.01.2025
8.0.0-preview.1.23110.8 7 29.01.2025
7.0.0 11 23.01.2025
7.0.0-rc.2.22472.3 6 23.01.2025
7.0.0-rc.1.22426.10 7 23.01.2025
7.0.0-preview.7.22375.6 8 23.01.2025
7.0.0-preview.6.22324.4 7 24.01.2025
7.0.0-preview.5.22301.12 6 24.01.2025
7.0.0-preview.4.22229.4 9 23.01.2025
7.0.0-preview.3.22175.4 7 24.01.2025
7.0.0-preview.2.22152.2 8 23.01.2025
7.0.0-preview.1.22076.8 9 23.01.2025
6.0.1 10 23.01.2025
6.0.0 13 23.01.2025
6.0.0-rc.2.21480.5 8 29.01.2025
6.0.0-rc.1.21451.13 7 29.01.2025
6.0.0-preview.7.21377.19 7 29.01.2025
6.0.0-preview.6.21352.12 7 23.01.2025
6.0.0-preview.5.21301.5 6 29.01.2025
6.0.0-preview.4.21253.7 10 23.01.2025
6.0.0-preview.3.21201.4 7 24.01.2025
6.0.0-preview.2.21154.6 6 23.01.2025
6.0.0-preview.1.21102.12 7 29.01.2025
5.0.0 12 23.01.2025
5.0.0-rc.2.20475.5 11 24.01.2025
5.0.0-rc.1.20451.14 6 30.01.2025
5.0.0-preview.8.20407.11 10 23.01.2025
5.0.0-preview.7.20364.11 9 23.01.2025
5.0.0-preview.6.20305.6 9 23.01.2025
5.0.0-preview.5.20278.1 8 23.01.2025
5.0.0-preview.4.20251.6 9 23.01.2025
5.0.0-preview.3.20215.2 9 23.01.2025
5.0.0-preview.2.20160.3 7 23.01.2025
5.0.0-preview.1.20120.4 8 23.01.2025
3.1.32 7 29.01.2025
3.1.31 10 23.01.2025
3.1.30 7 23.01.2025
3.1.29 7 29.01.2025
3.1.28 7 29.01.2025
3.1.27 6 29.01.2025
3.1.26 7 30.01.2025
3.1.25 6 28.01.2025
3.1.24 7 23.01.2025
3.1.23 6 23.01.2025
3.1.22 7 29.01.2025
3.1.21 7 29.01.2025
3.1.20 7 29.01.2025
3.1.19 7 29.01.2025
3.1.18 7 23.01.2025
3.1.17 8 29.01.2025
3.1.16 10 23.01.2025
3.1.15 6 28.01.2025
3.1.14 7 23.01.2025
3.1.13 8 29.01.2025
3.1.12 7 29.01.2025
3.1.11 8 29.01.2025
3.1.10 7 23.01.2025
3.1.9 11 29.01.2025
3.1.8 11 30.01.2025
3.1.7 12 29.01.2025
3.1.6 11 23.01.2025
3.1.5 12 29.01.2025
3.1.4 10 29.01.2025
3.1.3 11 23.01.2025
3.1.2 13 23.01.2025
3.1.1 11 24.01.2025
3.1.0 11 24.01.2025
3.1.0-preview3.19553.2 7 23.01.2025
3.1.0-preview2.19525.4 6 30.01.2025
3.1.0-preview1.19506.1 7 23.01.2025
3.0.3 11 29.01.2025
3.0.2 13 23.01.2025
3.0.1 11 23.01.2025
3.0.0 11 23.01.2025
3.0.0-rc1.19456.10 7 30.01.2025
3.0.0-preview9.19423.4 6 23.01.2025
3.0.0-preview8.19405.4 6 29.01.2025
3.0.0-preview7.19362.4 6 24.01.2025
3.0.0-preview6.19304.6 7 30.01.2025
3.0.0-preview5.19227.9 7 29.01.2025
3.0.0-preview4.19216.2 7 23.01.2025
3.0.0-preview3.19153.1 6 23.01.2025
3.0.0-preview.19074.2 6 23.01.2025
3.0.0-preview.18572.1 7 23.01.2025
2.2.0 10 24.01.2025
2.2.0-preview3-35497 6 23.01.2025
2.2.0-preview2-35157 7 23.01.2025
2.2.0-preview1-35029 7 29.01.2025
2.1.1 11 24.01.2025
2.1.0 11 29.01.2025
2.1.0-rc1-final 8 24.01.2025
2.1.0-preview2-final 9 23.01.2025
2.1.0-preview1-final 7 23.01.2025