Microsoft.Extensions.Http.Polly 10.0.0-preview.2.25164.1

Prefix Reserved
This is a prerelease version of Microsoft.Extensions.Http.Polly.
dotnet add package Microsoft.Extensions.Http.Polly --version 10.0.0-preview.2.25164.1
                    
NuGet\Install-Package Microsoft.Extensions.Http.Polly -Version 10.0.0-preview.2.25164.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="10.0.0-preview.2.25164.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="10.0.0-preview.2.25164.1" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.Extensions.Http.Polly" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.Extensions.Http.Polly --version 10.0.0-preview.2.25164.1
                    
#r "nuget: Microsoft.Extensions.Http.Polly, 10.0.0-preview.2.25164.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Microsoft.Extensions.Http.Polly&version=10.0.0-preview.2.25164.1&prerelease
                    
Install Microsoft.Extensions.Http.Polly as a Cake Addin
#tool nuget:?package=Microsoft.Extensions.Http.Polly&version=10.0.0-preview.2.25164.1&prerelease
                    
Install Microsoft.Extensions.Http.Polly as a Cake Tool

About

Microsoft.Extensions.Http.Polly integrates IHttpClientFactory with the Polly library to provide comprehensive resilience and transient fault-handling. It allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner.

[!NOTE] This package is deprecated. Please use either Microsoft.Extensions.Resilience or Microsoft.Extensions.Http.Resilience instead.

How to Use

To use Microsoft.Extensions.Http.Polly, follow these steps:

Installation

dotnet add package Microsoft.Extensions.Http.Polly

Usage

Handle transient faults

AddTransientHttpErrorPolicy can be used define a policy that handles transient errors:

builder.Services.AddHttpClient("PollyWaitAndRetry")
    .AddTransientHttpErrorPolicy(policyBuilder =>
        policyBuilder.WaitAndRetryAsync(
            retryCount: 3,
            retryNumber => TimeSpan.FromMilliseconds(600)));

In the preceding example, failed requests are retried up to three times with a delay of 600 ms between attempts.

Dynamically select policies

To dynamically inspect a request and decide which policy apply, use the AddPolicyHandler extension method:

var timeoutPolicy = Policy.TimeoutAsync<HttpResponseMessage>(
    TimeSpan.FromSeconds(10));
var longTimeoutPolicy = Policy.TimeoutAsync<HttpResponseMessage>(
    TimeSpan.FromSeconds(30));

builder.Services.AddHttpClient("PollyDynamic")
    .AddPolicyHandler(httpRequestMessage =>
        httpRequestMessage.Method == HttpMethod.Get
            ? timeoutPolicy
            : longTimeoutPolicy);

In this example, if the outgoing request is an HTTP GET, a 10-second timeout is applied. For any other HTTP method, a 30-second timeout is used.

Main Types

The main types provided by this package are:

  • PollyHttpClientBuilderExtensions: Provides extension methods for configuring PolicyHttpMessageHandler message handlers as part of an HttpClient message handler pipeline
  • PolicyHttpMessageHandler: A DelegatingHandler implementation that executes request processing surrounded by a Polly.Policy
  • PollyServiceCollectionExtensions: Provides convenience extension methods to register Polly.Registry.IPolicyRegistry<string> and Polly.Registry.IReadOnlyPolicyRegistry<string> in a service collection
  • HttpRequestMessageExtensions: Provides extension methods for HttpRequestMessage Polly integration

Additional Documentation

For additional documentation and examples, refer to the official documentation on using Polly-based handlers in ASP.NET Core.

Feedback & Contributing

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

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (790)

Showing the top 5 NuGet packages that depend on Microsoft.Extensions.Http.Polly:

Package Downloads
OpenIddict.Validation.SystemNetHttp

System.Net.Http integration package for the OpenIddict validation services.

Rystem.OpenAi

.Net wrapper for OpenAI with Dependency injection integration, factory integration: you may inject more than one endpoint, azure integration: you may swap among openai endpoint and any azure endpoint quickly and easily. You can calculate tokens and cost for each request (before the request) and for each response. You can access to the dashboard api to retrieve your current or previous billing.

Rystem.RepositoryFramework.Api.Client

Rystem.RepositoryFramework allows you to use correctly concepts like repository pattern, CQRS and DDD. You have interfaces for your domains, auto-generated api, auto-generated HttpClient to simplify connection "api to front-end", a functionality for auto-population in memory of your models, a functionality to simulate exceptions and waiting time from external sources to improve your implementation/business test and load test.

Omnia.Fx.NetCore

Package Description

OpenIddict.Client.SystemNetHttp

System.Net.Http integration package for the OpenIddict client services.

GitHub repositories (112)

Showing the top 5 popular GitHub repositories that depend on Microsoft.Extensions.Http.Polly:

Repository Stars
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
RayWangQvQ/BiliBiliToolPro
B 站(bilibili)自动任务工具,支持docker、青龙、k8s等多种部署方式。敏感肌也能用。
elsa-workflows/elsa-core
A .NET workflows library
LykosAI/StabilityMatrix
Multi-Platform Package Manager for Stable Diffusion
Version Downloads Last updated
10.0.0-preview.2.25164.1 650 3/18/2025
10.0.0-preview.1.25120.3 1,767 2/25/2025
9.0.3 385,586 3/11/2025
9.0.2 1,324,507 2/11/2025
9.0.1 1,290,589 1/14/2025
9.0.0 3,444,336 11/12/2024
9.0.0-rc.2.24474.3 88,699 10/8/2024
9.0.0-rc.1.24452.1 37,336 9/10/2024
9.0.0-preview.7.24406.2 7,022 8/13/2024
9.0.0-preview.6.24328.4 19,505 7/9/2024
9.0.0-preview.5.24306.11 36,994 6/11/2024
9.0.0-preview.4.24267.6 6,482 5/21/2024
9.0.0-preview.3.24172.13 13,526 4/11/2024
9.0.0-preview.2.24128.4 19,652 3/12/2024
9.0.0-preview.1.24081.5 7,369 2/13/2024
8.0.14 180,647 3/11/2025
8.0.13 620,057 2/11/2025
8.0.12 824,188 1/14/2025
8.0.11 2,895,936 11/12/2024
8.0.10 6,095,357 10/8/2024
8.0.8 7,043,417 8/13/2024
8.0.7 6,438,015 7/9/2024
8.0.6 6,824,731 5/28/2024
8.0.5 2,782,723 5/14/2024
8.0.4 5,483,080 4/9/2024
8.0.3 5,035,161 3/12/2024
8.0.2 4,501,372 2/13/2024
8.0.1 5,379,098 1/9/2024
8.0.0 9,698,784 11/14/2023
8.0.0-rc.2.23480.2 58,967 10/10/2023
8.0.0-rc.1.23421.29 31,490 9/12/2023
8.0.0-preview.7.23375.9 44,462 8/8/2023
8.0.0-preview.6.23329.11 23,755 7/11/2023
8.0.0-preview.5.23302.2 12,811 6/13/2023
8.0.0-preview.4.23260.4 237,046 5/16/2023
8.0.0-preview.3.23177.8 24,897 4/11/2023
8.0.0-preview.2.23153.2 25,514 3/14/2023
8.0.0-preview.1.23112.2 14,174 2/21/2023
7.0.20 451,786 5/28/2024
7.0.19 88,238 5/14/2024
7.0.18 285,136 4/9/2024
7.0.17 256,796 3/12/2024
7.0.16 397,692 2/13/2024
7.0.15 725,015 1/9/2024
7.0.14 1,499,834 11/14/2023
7.0.13 2,129,847 10/24/2023
7.0.12 5,795,488 10/10/2023
7.0.11 2,871,130 9/12/2023
7.0.10 4,612,195 8/8/2023
7.0.9 3,653,945 7/11/2023
7.0.8 1,729,120 6/22/2023
7.0.7 1,695,631 6/13/2023
7.0.5 8,775,912 4/11/2023
7.0.4 3,866,145 3/14/2023
7.0.3 2,937,226 2/14/2023
7.0.2 3,817,966 1/10/2023
7.0.1 2,449,635 12/13/2022
7.0.0 4,749,094 11/7/2022
7.0.0-rc.2.22476.2 24,277 10/11/2022
7.0.0-rc.1.22427.2 41,274 9/14/2022
7.0.0-preview.7.22376.6 34,013 8/9/2022
7.0.0-preview.6.22330.3 35,074 7/12/2022
7.0.0-preview.5.22303.8 11,799 6/14/2022
7.0.0-preview.4.22251.1 17,676 5/10/2022
7.0.0-preview.3.22178.4 9,456 4/13/2022
7.0.0-preview.2.22153.2 27,500 3/14/2022
7.0.0-preview.1.22109.13 7,084 2/17/2022
6.0.36 101,272 11/12/2024
6.0.35 136,220 10/8/2024
6.0.33 268,264 8/13/2024
6.0.32 215,190 7/9/2024
6.0.31 384,419 5/28/2024
6.0.30 104,994 5/14/2024
6.0.29 478,513 4/9/2024
6.0.28 504,682 3/12/2024
6.0.27 454,146 2/13/2024
6.0.26 1,225,749 1/9/2024
6.0.25 1,216,727 11/14/2023
6.0.24 701,835 10/24/2023
6.0.23 542,606 10/10/2023
6.0.22 806,437 9/12/2023
6.0.21 1,197,899 8/8/2023
6.0.20 1,038,956 7/11/2023
6.0.19 625,301 6/22/2023
6.0.18 557,380 6/13/2023
6.0.16 3,100,023 4/11/2023
6.0.15 1,378,663 3/14/2023
6.0.14 1,390,921 2/14/2023
6.0.13 2,127,643 1/10/2023
6.0.12 1,538,561 12/13/2022
6.0.11 2,527,954 11/7/2022
6.0.10 6,184,869 10/11/2022
6.0.9 5,481,068 9/13/2022
6.0.8 7,554,679 8/9/2022
6.0.7 5,549,007 7/12/2022
6.0.6 4,117,110 6/14/2022
6.0.5 5,009,093 5/10/2022
6.0.4 4,548,528 4/11/2022
6.0.3 4,649,042 3/8/2022
6.0.2 4,246,797 2/8/2022
6.0.1 6,692,782 12/14/2021
6.0.0 10,355,178 11/8/2021
6.0.0-rc.2.21480.10 35,506 10/12/2021
6.0.0-rc.1.21452.15 12,400 9/14/2021
6.0.0-preview.7.21378.6 16,866 8/10/2021
6.0.0-preview.6.21355.2 5,477 7/14/2021
6.0.0-preview.5.21301.17 12,788 6/15/2021
6.0.0-preview.4.21253.5 9,292 5/24/2021
6.0.0-preview.3.21201.13 10,961 4/8/2021
6.0.0-preview.2.21154.6 7,341 3/11/2021 6.0.0-preview.2.21154.6 is deprecated because it is no longer maintained.
6.0.0-preview.1.21103.6 26,478 2/12/2021 6.0.0-preview.1.21103.6 is deprecated because it is no longer maintained.
5.0.1 22,264,205 12/8/2020 5.0.1 is deprecated because it is no longer maintained.
5.0.0 4,366,696 11/9/2020 5.0.0 is deprecated because it is no longer maintained.
5.0.0-rc.2.20478.4 11,154 10/13/2020 5.0.0-rc.2.20478.4 is deprecated because it is no longer maintained.
5.0.0-rc.1.20451.7 8,908 9/14/2020 5.0.0-rc.1.20451.7 is deprecated because it is no longer maintained.
5.0.0-preview.8.20407.3 3,155 8/25/2020 5.0.0-preview.8.20407.3 is deprecated because it is no longer maintained.
5.0.0-preview.7.20365.4 10,479 7/21/2020 5.0.0-preview.7.20365.4 is deprecated because it is no longer maintained.
5.0.0-preview.6.20306.1 17,980 6/25/2020 5.0.0-preview.6.20306.1 is deprecated because it is no longer maintained.
5.0.0-preview.5.20278.3 3,993 6/10/2020 5.0.0-preview.5.20278.3 is deprecated because it is no longer maintained.
5.0.0-preview.4.20251.2 2,532 5/18/2020 5.0.0-preview.4.20251.2 is deprecated because it is no longer maintained.
5.0.0-preview.3.20215.2 10,416 4/23/2020 5.0.0-preview.3.20215.2 is deprecated because it is no longer maintained.
5.0.0-preview.2.20160.3 29,576 4/2/2020 5.0.0-preview.2.20160.3 is deprecated because it is no longer maintained.
5.0.0-preview.1.20120.4 4,217 3/16/2020 5.0.0-preview.1.20120.4 is deprecated because it is no longer maintained.
3.1.32 866,044 12/13/2022
3.1.31 145,431 11/8/2022
3.1.30 132,241 10/11/2022
3.1.29 136,679 9/13/2022
3.1.28 466,090 8/9/2022
3.1.27 107,228 7/12/2022
3.1.26 135,128 6/14/2022
3.1.25 307,762 5/10/2022
3.1.24 191,522 4/11/2022
3.1.23 247,174 3/8/2022
3.1.22 2,370,475 12/14/2021
3.1.21 713,425 11/7/2021
3.1.20 321,983 10/11/2021
3.1.19 522,541 9/14/2021
3.1.18 584,918 8/10/2021
3.1.17 997,919 7/13/2021
3.1.16 4,765,946 6/8/2021
3.1.15 1,166,844 5/11/2021
3.1.14 1,091,218 4/6/2021
3.1.13 3,131,342 3/9/2021
3.1.12 2,106,283 2/9/2021
3.1.11 683,723 1/12/2021
3.1.10 2,152,364 11/9/2020
3.1.9 2,939,308 10/13/2020
3.1.8 3,712,501 9/8/2020
3.1.7 5,873,649 8/11/2020
3.1.6 3,456,953 7/14/2020
3.1.5 4,995,932 6/9/2020
3.1.4 2,657,356 5/12/2020
3.1.3 3,385,623 3/24/2020
3.1.2 2,747,384 2/18/2020
3.1.1 3,260,866 1/14/2020
3.1.0 4,683,170 12/3/2019
3.1.0-preview3.19553.2 3,046 11/13/2019 3.1.0-preview3.19553.2 is deprecated because it is no longer maintained.
3.1.0-preview2.19525.4 1,612 11/1/2019 3.1.0-preview2.19525.4 is deprecated because it is no longer maintained.
3.1.0-preview1.19506.1 985 10/15/2019 3.1.0-preview1.19506.1 is deprecated because it is no longer maintained.
3.0.3 209,864 2/18/2020 3.0.3 is deprecated because it is no longer maintained.
3.0.2 45,352 1/14/2020 3.0.2 is deprecated because it is no longer maintained.
3.0.1 278,298 11/18/2019 3.0.1 is deprecated because it is no longer maintained.
3.0.0 2,721,704 9/23/2019 3.0.0 is deprecated because it is no longer maintained.
3.0.0-rc1.19456.10 6,266 9/16/2019 3.0.0-rc1.19456.10 is deprecated because it is no longer maintained.
3.0.0-preview9.19423.4 7,831 9/4/2019 3.0.0-preview9.19423.4 is deprecated because it is no longer maintained.
3.0.0-preview8.19405.4 4,671 8/13/2019 3.0.0-preview8.19405.4 is deprecated because it is no longer maintained.
3.0.0-preview7.19362.4 3,167 7/23/2019 3.0.0-preview7.19362.4 is deprecated because it is no longer maintained.
3.0.0-preview6.19304.6 4,118 6/12/2019 3.0.0-preview6.19304.6 is deprecated because it is no longer maintained.
3.0.0-preview5.19227.9 8,889 5/6/2019 3.0.0-preview5.19227.9 is deprecated because it is no longer maintained.
3.0.0-preview4.19216.2 1,158 4/18/2019 3.0.0-preview4.19216.2 is deprecated because it is no longer maintained.
3.0.0-preview3.19153.1 1,360 3/6/2019 3.0.0-preview3.19153.1 is deprecated because it is no longer maintained.
3.0.0-preview.19074.2 2,391 1/29/2019 3.0.0-preview.19074.2 is deprecated because it is no longer maintained.
3.0.0-preview.18572.1 2,090 12/4/2018 3.0.0-preview.18572.1 is deprecated because it is no longer maintained.
2.2.0 13,307,939 12/3/2018 2.2.0 is deprecated because it is no longer maintained.
2.2.0-preview3-35497 14,739 10/17/2018 2.2.0-preview3-35497 is deprecated because it is no longer maintained.
2.2.0-preview2-35157 6,403 9/12/2018 2.2.0-preview2-35157 is deprecated because it is no longer maintained.
2.2.0-preview1-35029 4,295 8/22/2018 2.2.0-preview1-35029 is deprecated because it is no longer maintained.
2.1.1 5,088,670 6/18/2018
2.1.0 2,394,186 5/29/2018
2.1.0-rc1-final 10,470 5/6/2018 2.1.0-rc1-final is deprecated because it is no longer maintained.
2.1.0-preview2-final 4,141 4/13/2018 2.1.0-preview2-final is deprecated because it is no longer maintained.