Rate limiting Minimal APIs in .NET with the built-in middleware
Public APIs are exposed to clients that may flood an endpoint with requests, whether from a bug, a faulty script or deliberate abuse. Since .NET 7, the framework includes rate limiting middleware, so no third-party package is needed. The article demonstrates a per-IP fixed-window policy that rejects excess requests immediately with a 429 status and a Retry-After header. It also covers applying the policy to specific endpoints, keeping health checks unlimited, and writing integration tests with WebApplicationFactory.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in