Skip to content

Clarify rate limiter ordering with UseStatusCodePagesWithReExecute - #37964

Merged
guardrex merged 3 commits into
dotnet:mainfrom
GrantTotinov:ratelimiter-statuscodepages-ordering-69942
Oct 23, 2026
Merged

guardrex merged 3 commits into
dotnet:mainfrom
GrantTotinov:ratelimiter-statuscodepages-ordering-69942

Conversation

@GrantTotinov

@GrantTotinov GrantTotinov commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes dotnet/aspnetcore#69942

When UseStatusCodePagesWithReExecute is registered after UseRateLimiter, re-execution skips the rate limiter, so the re-executed endpoint's rate limiting policy isn't applied.

Changes:

  • rate-limit.md: added a note and ordering example after the existing UseRouting guidance.
  • error-handling.md (.NET 10+): explained that middleware registered before the status code pages middleware doesn't run again during re-execution, with the same example.

I checked the behavior with a small .NET 10 app (fixed window policy, PermitLimit = 1, on /b; /a returns an empty 404):

Order 1st /b 2nd /b /a
UseRouting, UseRateLimiter, UseStatusCodePagesWithReExecute("/b") 200 429 404, body from /b (limiter bypassed)
UseStatusCodePagesWithReExecute("/b"), UseRouting, UseRateLimiter 200 429 429

I left the 8.0 and 9.0 includes unchanged to keep this small. Happy to add the same note there if you'd like.


Internal previews

File Preview link
aspnetcore/fundamentals/error-handling.md Learn preview
aspnetcore/fundamentals/error-handling/includes/error-handling8.md Learn preview
aspnetcore/fundamentals/error-handling/includes/error-handling9.md Learn preview
aspnetcore/performance/rate-limit.md Learn preview

Build report

Middleware registered before the status code pages middleware doesn't
run again when a request is re-executed, so UseRateLimiter must come
after UseStatusCodePagesWithReExecute for endpoint policies to apply
to the re-executed endpoint.

Fixes dotnet/aspnetcore#69942
Copilot AI balanced review requested due to automatic review settings October 22, 2026 01:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The documentation matches the linked framework issue, with only non-blocking API-reference formatting corrections remaining.

2 open issues

Review effort: Balanced

Comment thread aspnetcore/performance/rate-limit.md Resolved
@guardrex

Copy link
Copy Markdown
Collaborator

Thanks, @GrantTotinov! 🚀

  • Please apply Copilot's suggestions.
  • Update the article date to today's date.
  • Yes, please update the 8.0 and 9.0 INCLUDES files if this applies to those versions.

@GrantTotinov

Copy link
Copy Markdown
Contributor Author

@guardrex Done! Ive applied all the requested changes, including updating the 8.0 and 9.0 includes. Thanks for the review!

@guardrex

Copy link
Copy Markdown
Collaborator

Thanks, @GrantTotinov! 🚀 The changes will probably go live in a few hours.

@guardrex
guardrex merged commit 04c4aee into dotnet:main Oct 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify rate-limiter ordering with UseStatusCodePagesWithReExecute

3 participants