Microsoft.Extensions.Http 10.0.0

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
AspNetCore.HealthChecks.Uris
HealthChecks.Uris is a simple health check package for Uri groups.
79
AspNetCore.HealthChecks.Uris
HealthChecks.Uris is a simple health check package for Uri groups.
75
AspNetCore.HealthChecks.Uris
HealthChecks.Uris is a simple health check package for Uri groups.
72
AspNetCore.HealthChecks.Uris
HealthChecks.Uris is a simple health check package for Uri groups.
70
AspNetCore.HealthChecks.Uris
HealthChecks.Uris is a simple health check package for Uri groups.
69
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/cf2c5c9c6dca430b97aa96429b84d0da07eb77f1
69
IdentityServer4
OpenID Connect and OAuth 2.0 Framework for ASP.NET Core
68
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/67acc3d331454956fc06d6de2218a625e3e596f8
68
AspNetCore.HealthChecks.Uris
HealthChecks.Uris is a simple health check package for Uri groups.
68
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
68
AspNetCore.HealthChecks.Uris
HealthChecks.Uris is a simple health check package for Uri groups.
67
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/68bb6fb08f8f85bb3cf08953a0d2f4a254eaccff
67
AspNetCore.HealthChecks.Uris
HealthChecks.Uris is a simple health check package for Uri groups.
66
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/aee5e4080331553ea9dfb7fb388b6d72f715bf6a
65
AspNetCore.HealthChecks.Uris
HealthChecks.Uris is a simple health check package for Uri groups.
65

https://go.microsoft.com/fwlink/?LinkID=799421

.NET Framework 4.6.2

.NET Standard 2.0

.NET 10.0

.NET 9.0

.NET 8.0

Version Downloads Last updated
10.0.0 6 11/11/2025
10.0.0-rc.2.25502.107 9 10/15/2025
10.0.0-rc.1.25451.107 16 09/11/2025
10.0.0-preview.7.25380.108 15 08/14/2025
10.0.0-preview.6.25358.103 17 07/17/2025
10.0.0-preview.5.25277.114 21 06/14/2025
10.0.0-preview.4.25258.110 25 05/13/2025
10.0.0-preview.3.25171.5 31 04/12/2025
10.0.0-preview.2.25163.2 32 03/23/2025
10.0.0-preview.1.25080.5 34 02/25/2025
9.0.11 0 11/11/2025
9.0.10 6 10/15/2025
9.0.9 10 09/11/2025
9.0.8 14 08/07/2025
9.0.7 16 07/13/2025
9.0.6 20 06/12/2025
9.0.5 28 05/15/2025
9.0.4 33 04/11/2025
9.0.3 33 03/12/2025
9.0.2 41 02/14/2025
9.0.1 38 01/17/2025
9.0.0 50 11/13/2024
9.0.0-rc.2.24473.5 43 10/16/2024
9.0.0-rc.1.24431.7 37 09/11/2024
9.0.0-preview.7.24405.7 46 08/15/2024
9.0.0-preview.6.24327.7 51 07/11/2024
9.0.0-preview.5.24306.7 49 06/12/2024
9.0.0-preview.4.24266.19 44 05/23/2024
9.0.0-preview.3.24172.9 47 04/20/2024
9.0.0-preview.2.24128.5 50 03/19/2024
9.0.0-preview.1.24080.9 54 03/05/2024
8.0.1 51 10/17/2024
8.0.0 64 11/15/2023
8.0.0-rc.2.23479.6 49 10/19/2023
8.0.0-rc.1.23419.4 55 09/13/2023
8.0.0-preview.7.23375.6 50 08/24/2023
8.0.0-preview.6.23329.7 58 07/23/2023
8.0.0-preview.5.23280.8 49 07/05/2023
8.0.0-preview.4.23259.5 52 05/20/2023
8.0.0-preview.3.23174.8 46 05/13/2023
8.0.0-preview.2.23128.3 50 07/07/2023
8.0.0-preview.1.23110.8 55 02/25/2023
7.0.0 64 12/07/2022
7.0.0-rc.2.22472.3 55 07/03/2023
7.0.0-rc.1.22426.10 58 07/05/2023
7.0.0-preview.7.22375.6 57 11/05/2022
7.0.0-preview.6.22324.4 57 07/08/2023
7.0.0-preview.5.22301.12 49 05/06/2023
7.0.0-preview.4.22229.4 55 09/24/2022
7.0.0-preview.3.22175.4 48 06/29/2023
7.0.0-preview.2.22152.2 56 07/05/2023
7.0.0-preview.1.22076.8 61 09/26/2022
6.0.2-mauipre.1.22102.15 56 10/22/2022
6.0.2-mauipre.1.22054.8 53 11/18/2022
6.0.1 42 11/18/2024
6.0.0 61 07/28/2022
6.0.0-rc.2.21480.5 58 05/27/2023
6.0.0-rc.1.21451.13 49 07/04/2023
6.0.0-preview.7.21377.19 58 10/02/2022
6.0.0-preview.6.21352.12 47 07/05/2023
6.0.0-preview.5.21301.5 55 05/04/2023
6.0.0-preview.4.21253.7 53 04/25/2023
6.0.0-preview.3.21201.4 51 11/15/2022
6.0.0-preview.2.21154.6 59 11/16/2022
6.0.0-preview.1.21102.12 48 05/03/2023
5.0.0 61 07/03/2022
5.0.0-rc.2.20475.5 49 05/07/2023
5.0.0-rc.1.20451.14 50 05/12/2023
5.0.0-preview.8.20407.11 48 07/18/2023
5.0.0-preview.7.20364.11 60 07/03/2023
5.0.0-preview.6.20305.6 46 07/03/2023
5.0.0-preview.5.20278.1 54 02/20/2023
5.0.0-preview.4.20251.6 54 05/23/2023
5.0.0-preview.3.20215.2 49 05/19/2023
5.0.0-preview.2.20160.3 59 10/11/2022
5.0.0-preview.1.20120.4 60 01/18/2023
3.1.32 56 05/02/2023
3.1.31 57 01/17/2023
3.1.30 47 02/25/2023
3.1.29 57 12/19/2022
3.1.28 63 09/30/2022
3.1.27 62 10/11/2022
3.1.26 57 05/12/2023
3.1.25 53 10/03/2022
3.1.24 68 11/16/2022
3.1.23 61 10/03/2022
3.1.22 49 09/29/2022
3.1.21 54 10/08/2022
3.1.20 58 11/30/2022
3.1.19 54 09/29/2022
3.1.18 47 09/23/2022
3.1.17 56 09/26/2022
3.1.16 62 09/27/2022
3.1.15 53 10/08/2022
3.1.14 54 12/21/2022
3.1.13 51 05/16/2023
3.1.12 51 09/26/2022
3.1.11 55 10/07/2022
3.1.10 57 09/28/2022
3.1.9 57 09/25/2022
3.1.8 65 09/23/2022
3.1.7 69 11/19/2022
3.1.6 59 11/06/2022
3.1.5 67 11/30/2022
3.1.4 57 04/18/2023
3.1.3 65 09/23/2022
3.1.2 52 09/28/2022
3.1.1 67 09/22/2022
3.1.0 57 11/05/2022
3.1.0-preview3.19553.2 53 10/23/2022
3.1.0-preview2.19525.4 53 12/04/2022
3.1.0-preview1.19506.1 49 05/10/2023
3.0.3 60 10/29/2022
3.0.2 66 09/22/2022
3.0.1 60 11/19/2022
3.0.0 63 09/29/2022
3.0.0-rc1.19456.10 44 07/13/2023
3.0.0-preview9.19423.4 47 07/08/2023
3.0.0-preview8.19405.4 51 05/03/2023
3.0.0-preview7.19362.4 49 07/05/2023
3.0.0-preview6.19304.6 52 11/08/2022
3.0.0-preview5.19227.9 57 11/28/2022
3.0.0-preview4.19216.2 47 07/08/2023
3.0.0-preview3.19153.1 55 07/04/2023
3.0.0-preview.19074.2 47 07/03/2023
3.0.0-preview.18572.1 51 03/18/2023
2.2.0 66 09/23/2022
2.2.0-preview3-35497 57 10/10/2022
2.2.0-preview2-35157 53 05/24/2023
2.2.0-preview1-35029 49 10/26/2022
2.1.1 59 06/07/2022
2.1.0 61 09/30/2022
2.1.0-rc1-final 55 05/20/2023
2.1.0-preview2-final 51 09/23/2022
2.1.0-preview1-final 53 11/24/2022