Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nimanikoo/Dotnet-RateLimiter/llms.txt
Use this file to discover all available pages before exploring further.
RedisRateLimitAttribute is a lightweight marker that you place on any controller action (or minimal-API endpoint) to opt it into distributed Redis rate limiting. It carries two values — a request ceiling and a window duration — which RedisRateLimitingMiddleware reads at runtime from the endpoint’s metadata collection. Endpoints that do not carry this attribute are skipped entirely by the middleware, so you have precise, per-route control over which paths are protected.
Namespace
Class Declaration
System.Attribute. No additional base classes or interfaces are involved.
Constructor
| Parameter | Type | Description |
|---|---|---|
maxRequests | int | Maximum number of requests allowed within the window. |
windowSeconds | int | Length of the rate-limit window in seconds. |
Properties
The maximum number of requests a single client is permitted to make to the decorated
endpoint within one window. The middleware passes this value directly to
RedisRateLimiter.IsAllowedAsync as maxRequests.The length of the rate-limit window expressed in seconds. The middleware converts this
to a
TimeSpan via TimeSpan.FromSeconds(rateLimitAttr.WindowSeconds) before passing
it to RedisRateLimiter.IsAllowedAsync. It is also written verbatim into the
Retry-After response header when a 429 is returned.Full Source
Usage on a Controller Action
Decorate any controller action with[RedisRateLimit(maxRequests, windowSeconds)]:
How the Middleware Reads This Attribute
RedisRateLimitingMiddleware retrieves the attribute from the current endpoint’s metadata
on every request:
IEndpointMetadataCollection with all attributes
declared on a matched action, so GetMetadata<T>() returns the attribute instance when
present and null otherwise.
[RedisRateLimit] works exclusively with RedisRateLimitingMiddleware. It does not
integrate with ASP.NET Core’s built-in [EnableRateLimiting] mechanism or the
IRateLimiterPolicy pipeline registered via services.AddRateLimiter(...). The two
systems are independent — you can use both on the same application without conflict.