Skip to content

ASPNET Rate Limiting — Controlling API Request Rates in .NET

DodaTech Updated 2026-06-28 1 min read

In this tutorial, you'll learn about ASPNET Rate Limiting. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

ASP.NET Core 7+ includes built-in rate limiting middleware supporting multiple algorithms and customizable policies.

builder.Services.AddRateLimiter(options =>
{
    options.AddFixedWindowLimiter("Fixed", cfg =>
    {
        cfg.PermitLimit = 100;
        cfg.Window = TimeSpan.FromMinutes(1);
        cfg.QueueProcessingOrder = QueueProcessingOrder.OldestFirst;
        cfg.QueueLimit = 10;
    });

    options.AddSlidingWindowLimiter("Sliding", cfg =>
    {
        cfg.PermitLimit = 100;
        cfg.Window = TimeSpan.FromMinutes(1);
        cfg.SegmentsPerWindow = 6;
    });

    options.RejectionStatusCode = StatusCodes.Status429TooManyRequests;
});

app.UseRateLimiter();

[EnableRateLimiting("Fixed")]
public class ScanController : ControllerBase { ... }

Rate limiting protects your API from abuse and ensures fair resource distribution across all consumers.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro