October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

ASP.NET Core Retries: When to Retry and How to Avoid Duplicate Effects

A timeout does not mean an operation failed. Configure ASP.NET Core retries around endpoint semantics, and use stable request identifiers to prevent duplicate effects.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A timeout does not prove that an operation failed. The server may have committed a new order or database record before the response was lost, so a client that retries blindly can apply the same effect twice. To prevent duplicate records, make retries match the operation’s semantics and have the server recognize repeated logical requests using a stable identifier, such as an idempotency key.

Why a timeout can create a duplicate

A retry is another attempt after a transient failure or timeout. But a timed-out client often cannot tell whether the server never received the request, failed before committing it, or completed the operation and lost the response on its way back. Microsoft cautions that retrying a POST that inserts a database record can create duplicate data. Microsoft’s HTTP resilience guidance describes this risk.

As an Amazon Associate I earn from qualifying purchases.

For example, an API client sends a request to create an order. The server saves the order, but the response times out. If the client sends the same creation request again and the server treats it as a new operation, the customer may end up with two orders. The client’s uncertainty is the problem: the timeout alone does not reveal what happened on the server.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is repeating this HTTP operation safe?

HTTP idempotency concerns the intended effect on resource state: repeating an identical request should have the same intended effect as processing it once. It does not require identical response bytes, and it is not the same as safety. A method can change state and still be idempotent. Microsoft’s HTTP method overview classifies methods as follows:

Methods HTTP semantics What that means for retries
GET, HEAD, OPTIONS, TRACE Idempotent Repeated requests are defined to have the same intended effect on state.
PUT, DELETE Idempotent Repeated requests are defined to have the same intended effect on state, though they can modify or remove state.
POST, PATCH, CONNECT Non-idempotent by default Repeating a request can apply an effect again.

The method is a useful signal, not proof of what a particular endpoint does. An application might implement a POST operation to be duplicate-aware, or make an endpoint behave differently from what its method’s usual semantics suggest. Evaluate the operation itself before enabling retries.

What the standard .NET HTTP retry handler does

Microsoft’s current guidance uses Microsoft.Extensions.Http.Resilience for resilient HttpClient pipelines. The standard handler retries all HTTP methods by default, which can be risky for operations that create records or otherwise apply non-idempotent effects. The documentation provides DisableFor(HttpMethod.Post, HttpMethod.Delete) to exclude those methods, and DisableForUnsafeHttpMethods() to exclude POST, PATCH, PUT, DELETE, and CONNECT. Choose based on the behavior of your endpoints and whether repeated requests are protected against duplicates.

The documented standard pipeline orders its strategies as rate limiter, total timeout, retry, circuit breaker, and per-attempt timeout. Its defaults are package defaults to inspect and configure deliberately, not a universal policy for every workload:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Setting Documented standard-handler default
Concurrency limiter 1,000 permits; no queue
Total timeout 30 seconds
Retries Up to three attempts, using exponential backoff with jitter and a two-second delay
Circuit breaker 10% failure ratio; minimum throughput of 100; 30-second sampling duration; five-second break duration
Per-attempt timeout 10 seconds

The standard handler’s retry and circuit-breaker strategies handle HTTP 500 and above, 408, 429, HttpRequestException, and TimeoutRejectedException, according to Microsoft’s documentation. Whether another attempt is appropriate still depends on whether the operation can safely be repeated.

For current package direction, Microsoft identifies Microsoft.Extensions.Http.Resilience for HTTP clients and Microsoft.Extensions.Resilience for broader application mechanisms; both are built on Polly. Microsoft says Microsoft.Extensions.Http.Polly is deprecated. See the .NET resilience overview for the package context.

How an idempotency key prevents duplicate effects

An idempotency key is a stable identifier for one logical operation. A client reuses that identifier when retrying the same operation; the server records or otherwise tracks processed identifiers so it can recognize a repeat instead of applying the effect as a new operation. The key turns two delivery attempts into one identifiable logical request.

This is an application-level design pattern, not a universal HTTP header contract established by the cited Microsoft guidance. Microsoft’s Azure Architecture Center says to first determine whether an operation is naturally idempotent and, if not, apply artificial idempotency by tracking processed message IDs and handling duplicates proactively or reactively. See its guidance on idempotent consumers. The same duplicate-tracking idea can be applied to API requests, with the API defining the contract.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before implementing request deduplication, document these decisions:

Best Value
Sale
Programming ASP.NET Core (Developer Reference)
  • Applying all key ASP.NET Core components, including MVC for HTML generation, .NET Core, EF Core, ASP.NET Identity, dependency injection, and more
  • Integrating ASP.NET Core with leading client-side frameworks, including Bootstrap
  • ASP.NET Core code for implementing business logic and data transformations
  • Handling configuration, routing, controllers, views, and common tasks (including posting forms and presenting data)
  • Performing complementary tasks: error handling, logging, application design, authentication, localization, and more
  • Identity: What uniquely identifies one logical operation, and how does the client retain and reuse that identifier for retries?
  • Scope: Is the identifier unique per account, endpoint, or another defined boundary?
  • Payload reuse: What happens if a client reuses an identifier with a different request body?
  • Concurrency: How are simultaneous requests carrying the same identifier serialized or reconciled?
  • Retention: How long does the server retain processed identifiers, and what behavior applies after expiry?
  • Duplicate response: Does a repeated request receive the original result, a status indicating prior processing, or another documented response?

These choices are not specified as universal rules by Microsoft’s duplicate-tracking guidance. For a third-party payment or API service, follow that provider’s contract rather than assuming a header name, key lifetime, or replay behavior.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose retry policy and duplicate handling together

A retry policy decides whether the client makes another attempt after a failure. Duplicate tracking lets the server identify whether that attempt represents an operation it has already processed. They address different failure modes, so neither is a substitute for the other.

Approach Best fit Trade-off
Rely on natural idempotency The operation’s repeated effect is already equivalent to one execution. Simple to retry, but confirm the endpoint really preserves the intended state.
Track request or message identifiers A repeated non-idempotent operation must not apply its effect twice. Protects the logical operation, but requires a clearly defined server-side duplicate contract.
Retry across all methods Only where every operation is safe to repeat or duplicate-aware. Convenient, but can replay unsafe operations.
Disable retries for unsafe methods Operations that lack duplicate protection and should not be replayed automatically. Reduces accidental replay, but does not itself recover a request whose outcome is unknown.

For ASP.NET Core clients, configure the resilience pipeline deliberately rather than inheriting all-method retries without review. For operations that must recover from ambiguous failures, pair an appropriate retry policy with server-side duplicate recognition. The practical rule is to retry only when another attempt is safe, or make the operation duplicate-aware first.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

Bestseller No. 2
SaleBestseller No. 5
Programming ASP.NET Core (Developer Reference)
Programming ASP.NET Core (Developer Reference)
Integrating ASP.NET Core with leading client-side frameworks, including Bootstrap; ASP.NET Core code for implementing business logic and data transformations
$24.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.