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 (797)

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 (116)

Showing the top 20 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
anjoy8/Blog.Core
💖 ASP.NET Core 8.0 全家桶教程,前后端分离后端接口,vue教程姊妹篇,官方文档:
openiddict/openiddict-core
Flexible and versatile OAuth 2.0/OpenID Connect stack for .NET
Xabaril/AspNetCore.Diagnostics.HealthChecks
Enterprise HealthChecks for ASP.NET Core Diagnostics Package
Scighost/Starward
Game Launcher for miHoYo - 米家游戏启动器
fullstackhero/blazor-starter-kit
Clean Architecture Template for Blazor WebAssembly Built with MudBlazor Components.
dotnet/extensions
This repository contains a suite of libraries that provide facilities commonly needed when creating production-ready applications.
microsoft/PowerApps-Samples
Sample code for Power Apps, including Dataverse, model-driven apps, canvas apps, Power Apps component framework, portals, and AI Builder.
NuGet/NuGetGallery
NuGet Gallery is a package repository that powers https://www.nuget.org. Use this repo for reporting NuGet.org issues.
AlphaYu/adnc
.NET微服务/分布式开发框架,同时也适用于单体架构系统的开发。
masastack/MASA.Blazor
Blazor UI component library based on Material Design. Support Blazor Server, Blazor WebAssembly and MAUI Blazor.
abpframework/abp-samples
Sample solutions built with the ABP Framework
OfficeDev/Microsoft-Teams-Samples
Welcome to the Microsoft Teams samples repository. Here you will find task-focused samples in C#, JavaScript and TypeScript to help you get started with the Microsoft Teams App!
ldqk/Masuit.MyBlogs
基于C#/.NET8的 masuit.org个人博客站项目源码,https://masuit.org ,供参考、学习、引用、非商业性质的部署。
desenvolvedor-io/dev-store
A microservices e-commerce reference application built with ASP.NET 6
DuendeArchive/IdentityModel
.NET standard helper library for claims-based identity, OAuth 2.0 and OpenID Connect.
Version Downloads Last updated
10.0.0-preview.2.25164.1 1,218 3/18/2025
10.0.0-preview.1.25120.3 2,023 2/25/2025
9.0.4 775 4/8/2025
9.0.3 657,996 3/11/2025
9.0.2 1,489,822 2/11/2025
9.0.1 1,374,099 1/14/2025
9.0.0 3,576,863 11/12/2024
9.0.0-rc.2.24474.3 91,212 10/8/2024
9.0.0-rc.1.24452.1 38,049 9/10/2024
9.0.0-preview.7.24406.2 7,258 8/13/2024
9.0.0-preview.6.24328.4 19,610 7/9/2024
9.0.0-preview.5.24306.11 37,064 6/11/2024
9.0.0-preview.4.24267.6 6,811 5/21/2024
9.0.0-preview.3.24172.13 13,673 4/11/2024
9.0.0-preview.2.24128.4 19,804 3/12/2024
9.0.0-preview.1.24081.5 7,456 2/13/2024
8.0.15 411 4/8/2025
8.0.14 290,103 3/11/2025
8.0.13 676,774 2/11/2025
8.0.12 874,553 1/14/2025
8.0.11 3,029,197 11/12/2024
8.0.10 6,295,194 10/8/2024
8.0.8 7,207,806 8/13/2024
8.0.7 6,575,838 7/9/2024
8.0.6 6,945,416 5/28/2024
8.0.5 2,831,168 5/14/2024
8.0.4 5,565,702 4/9/2024
8.0.3 5,085,550 3/12/2024
8.0.2 4,545,274 2/13/2024
8.0.1 5,455,492 1/9/2024
8.0.0 9,847,299 11/14/2023
8.0.0-rc.2.23480.2 59,241 10/10/2023
8.0.0-rc.1.23421.29 31,546 9/12/2023
8.0.0-preview.7.23375.9 44,527 8/8/2023
8.0.0-preview.6.23329.11 23,821 7/11/2023
8.0.0-preview.5.23302.2 12,836 6/13/2023
8.0.0-preview.4.23260.4 240,598 5/16/2023
8.0.0-preview.3.23177.8 25,032 4/11/2023
8.0.0-preview.2.23153.2 25,548 3/14/2023
8.0.0-preview.1.23112.2 14,235 2/21/2023
7.0.20 464,167 5/28/2024
7.0.19 89,619 5/14/2024
7.0.18 289,592 4/9/2024
7.0.17 257,796 3/12/2024
7.0.16 401,339 2/13/2024
7.0.15 727,979 1/9/2024
7.0.14 1,506,727 11/14/2023
7.0.13 2,141,478 10/24/2023
7.0.12 5,807,918 10/10/2023
7.0.11 2,883,060 9/12/2023
7.0.10 4,624,540 8/8/2023
7.0.9 3,667,552 7/11/2023
7.0.8 1,735,719 6/22/2023
7.0.7 1,701,140 6/13/2023
7.0.5 8,817,226 4/11/2023
7.0.4 3,870,981 3/14/2023
7.0.3 2,945,337 2/14/2023
7.0.2 3,825,800 1/10/2023
7.0.1 2,456,567 12/13/2022
7.0.0 4,765,505 11/7/2022
7.0.0-rc.2.22476.2 24,751 10/11/2022
7.0.0-rc.1.22427.2 41,307 9/14/2022
7.0.0-preview.7.22376.6 34,092 8/9/2022
7.0.0-preview.6.22330.3 35,141 7/12/2022
7.0.0-preview.5.22303.8 11,801 6/14/2022
7.0.0-preview.4.22251.1 17,703 5/10/2022
7.0.0-preview.3.22178.4 9,457 4/13/2022
7.0.0-preview.2.22153.2 27,576 3/14/2022
7.0.0-preview.1.22109.13 7,093 2/17/2022
6.0.36 108,272 11/12/2024
6.0.35 139,873 10/8/2024
6.0.33 275,954 8/13/2024
6.0.32 220,715 7/9/2024
6.0.31 388,052 5/28/2024
6.0.30 106,380 5/14/2024
6.0.29 481,555 4/9/2024
6.0.28 512,897 3/12/2024
6.0.27 456,091 2/13/2024
6.0.26 1,237,381 1/9/2024
6.0.25 1,224,408 11/14/2023
6.0.24 709,956 10/24/2023
6.0.23 545,064 10/10/2023
6.0.22 810,923 9/12/2023
6.0.21 1,203,424 8/8/2023
6.0.20 1,043,421 7/11/2023
6.0.19 627,917 6/22/2023
6.0.18 560,105 6/13/2023
6.0.16 3,115,457 4/11/2023
6.0.15 1,389,412 3/14/2023
6.0.14 1,397,755 2/14/2023
6.0.13 2,134,509 1/10/2023
6.0.12 1,544,270 12/13/2022
6.0.11 2,538,032 11/7/2022
6.0.10 6,211,249 10/11/2022
6.0.9 5,501,441 9/13/2022
6.0.8 7,573,727 8/9/2022
6.0.7 5,570,468 7/12/2022
6.0.6 4,128,200 6/14/2022
6.0.5 5,024,231 5/10/2022
6.0.4 4,561,489 4/11/2022
6.0.3 4,658,966 3/8/2022
6.0.2 4,254,901 2/8/2022
6.0.1 6,707,592 12/14/2021
6.0.0 10,483,083 11/8/2021
6.0.0-rc.2.21480.10 35,507 10/12/2021
6.0.0-rc.1.21452.15 12,416 9/14/2021
6.0.0-preview.7.21378.6 16,867 8/10/2021
6.0.0-preview.6.21355.2 5,479 7/14/2021
6.0.0-preview.5.21301.17 12,793 6/15/2021
6.0.0-preview.4.21253.5 9,295 5/24/2021
6.0.0-preview.3.21201.13 10,980 4/8/2021
6.0.0-preview.2.21154.6 7,344 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,538 2/12/2021 6.0.0-preview.1.21103.6 is deprecated because it is no longer maintained.
5.0.1 22,323,563 12/8/2020 5.0.1 is deprecated because it is no longer maintained.
5.0.0 4,375,514 11/9/2020 5.0.0 is deprecated because it is no longer maintained.
5.0.0-rc.2.20478.4 11,160 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,911 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,163 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,484 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,986 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,997 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,539 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,421 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,612 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,222 3/16/2020 5.0.0-preview.1.20120.4 is deprecated because it is no longer maintained.
3.1.32 876,637 12/13/2022
3.1.31 146,232 11/8/2022
3.1.30 133,126 10/11/2022
3.1.29 137,178 9/13/2022
3.1.28 469,423 8/9/2022
3.1.27 107,650 7/12/2022
3.1.26 135,439 6/14/2022
3.1.25 309,276 5/10/2022
3.1.24 191,790 4/11/2022
3.1.23 248,942 3/8/2022
3.1.22 2,378,701 12/14/2021
3.1.21 715,014 11/7/2021
3.1.20 323,465 10/11/2021
3.1.19 524,205 9/14/2021
3.1.18 588,707 8/10/2021
3.1.17 998,937 7/13/2021
3.1.16 4,779,066 6/8/2021
3.1.15 1,170,205 5/11/2021
3.1.14 1,096,128 4/6/2021
3.1.13 3,144,077 3/9/2021
3.1.12 2,109,086 2/9/2021
3.1.11 684,216 1/12/2021
3.1.10 2,155,764 11/9/2020
3.1.9 2,942,228 10/13/2020
3.1.8 3,717,030 9/8/2020
3.1.7 5,928,622 8/11/2020
3.1.6 3,465,787 7/14/2020
3.1.5 5,002,325 6/9/2020
3.1.4 2,663,369 5/12/2020
3.1.3 3,391,046 3/24/2020
3.1.2 2,752,091 2/18/2020
3.1.1 3,274,956 1/14/2020
3.1.0 4,695,720 12/3/2019
3.1.0-preview3.19553.2 3,051 11/13/2019 3.1.0-preview3.19553.2 is deprecated because it is no longer maintained.
3.1.0-preview2.19525.4 1,616 11/1/2019 3.1.0-preview2.19525.4 is deprecated because it is no longer maintained.
3.1.0-preview1.19506.1 989 10/15/2019 3.1.0-preview1.19506.1 is deprecated because it is no longer maintained.
3.0.3 210,821 2/18/2020 3.0.3 is deprecated because it is no longer maintained.
3.0.2 45,453 1/14/2020 3.0.2 is deprecated because it is no longer maintained.
3.0.1 279,103 11/18/2019 3.0.1 is deprecated because it is no longer maintained.
3.0.0 2,726,549 9/23/2019 3.0.0 is deprecated because it is no longer maintained.
3.0.0-rc1.19456.10 6,270 9/16/2019 3.0.0-rc1.19456.10 is deprecated because it is no longer maintained.
3.0.0-preview9.19423.4 7,834 9/4/2019 3.0.0-preview9.19423.4 is deprecated because it is no longer maintained.
3.0.0-preview8.19405.4 4,675 8/13/2019 3.0.0-preview8.19405.4 is deprecated because it is no longer maintained.
3.0.0-preview7.19362.4 3,171 7/23/2019 3.0.0-preview7.19362.4 is deprecated because it is no longer maintained.
3.0.0-preview6.19304.6 4,122 6/12/2019 3.0.0-preview6.19304.6 is deprecated because it is no longer maintained.
3.0.0-preview5.19227.9 8,893 5/6/2019 3.0.0-preview5.19227.9 is deprecated because it is no longer maintained.
3.0.0-preview4.19216.2 1,162 4/18/2019 3.0.0-preview4.19216.2 is deprecated because it is no longer maintained.
3.0.0-preview3.19153.1 1,364 3/6/2019 3.0.0-preview3.19153.1 is deprecated because it is no longer maintained.
3.0.0-preview.19074.2 2,395 1/29/2019 3.0.0-preview.19074.2 is deprecated because it is no longer maintained.
3.0.0-preview.18572.1 2,095 12/4/2018 3.0.0-preview.18572.1 is deprecated because it is no longer maintained.
2.2.0 13,333,134 12/3/2018 2.2.0 is deprecated because it is no longer maintained.
2.2.0-preview3-35497 14,743 10/17/2018 2.2.0-preview3-35497 is deprecated because it is no longer maintained.
2.2.0-preview2-35157 6,409 9/12/2018 2.2.0-preview2-35157 is deprecated because it is no longer maintained.
2.2.0-preview1-35029 4,302 8/22/2018 2.2.0-preview1-35029 is deprecated because it is no longer maintained.
2.1.1 5,108,458 6/18/2018
2.1.0 2,407,801 5/29/2018
2.1.0-rc1-final 10,476 5/6/2018 2.1.0-rc1-final is deprecated because it is no longer maintained.
2.1.0-preview2-final 4,151 4/13/2018 2.1.0-preview2-final is deprecated because it is no longer maintained.