Microsoft.Extensions.Http.Polly
10.0.0-preview.6.25321.102
Prefix Reserved
See the version list below for details.
dotnet add package Microsoft.Extensions.Http.Polly --version 10.0.0-preview.6.25321.102
NuGet\Install-Package Microsoft.Extensions.Http.Polly -Version 10.0.0-preview.6.25321.102
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="10.0.0-preview.6.25321.102" />
<PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="10.0.0-preview.6.25321.102" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" />
paket add Microsoft.Extensions.Http.Polly --version 10.0.0-preview.6.25321.102
#r "nuget: Microsoft.Extensions.Http.Polly, 10.0.0-preview.6.25321.102"
#:package Microsoft.Extensions.Http.Polly@10.0.0-preview.6.25321.102
#addin nuget:?package=Microsoft.Extensions.Http.Polly&version=10.0.0-preview.6.25321.102&prerelease
#tool nuget:?package=Microsoft.Extensions.Http.Polly&version=10.0.0-preview.6.25321.102&prerelease
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.
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 configuringPolicyHttpMessageHandler
message handlers as part of anHttpClient
message handler pipelinePolicyHttpMessageHandler
: ADelegatingHandler
implementation that executes request processing surrounded by aPolly.Policy
PollyServiceCollectionExtensions
: Provides convenience extension methods to registerPolly.Registry.IPolicyRegistry<string>
andPolly.Registry.IReadOnlyPolicyRegistry<string>
in a service collectionHttpRequestMessageExtensions
: Provides extension methods forHttpRequestMessage
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 | Versions 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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. |
-
.NETStandard 2.0
- Microsoft.Extensions.Http (>= 10.0.0-preview.6.25321.102)
- Polly (>= 7.2.4)
- Polly.Extensions.Http (>= 3.0.0)
GitHub repositories (120)
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!
|
|
meysamhadeli/booking-microservices
A practical microservices with the latest technologies and architectures like Vertical Slice Architecture, Event Sourcing, CQRS, DDD, gRpc, MongoDB, RabbitMq, Masstransit, and Aspire in .Net 9.
|
|
rogerfar/rdt-client
Real-Debrid Client Proxy
|
|
ldqk/Masuit.MyBlogs
基于C#/.NET8的 masuit.org个人博客站项目源码,https://masuit.org ,供参考、学习、引用、非商业性质的部署。
|
Version | Downloads | Last Updated |
---|---|---|
10.0.0-preview.7.25380.108 | 0 | 8/11/2025 |
10.0.0-preview.7.25380.105 | 0 | 8/6/2025 |
10.0.0-preview.6.25358.103 | 0 | 7/17/2025 |
10.0.0-preview.6.25321.102 | 0 | 6/25/2025 |
10.0.0-preview.5.25280.105 | 0 | 6/2/2025 |
10.0.0-preview.5.25277.114 | 0 | 6/3/2025 |
10.0.0-preview.5.25277.101 | 0 | 5/29/2025 |
10.0.0-preview.5.25266.103 | 0 | 5/20/2025 |
10.0.0-preview.4.25255.103 | 0 | 5/12/2025 |
9.0.7 | 0 | 7/11/2025 |
3.0.0-preview.19074.2 | 2 | 1/28/2019 |
3.0.0-preview.18572.1 | 1 | 11/30/2018 |