ASP.NET Core API Rate Limiting Not Functioning as Expected with Custom Policy
Could someone explain I'm sure I'm missing something obvious here, but I've been struggling with this for a few days now and could really use some help. I'm currently implementing a rate-limiting feature in my ASP.NET Core 6 Web API using the `AspNetCoreRateLimit` library, but I'm running into issues where the limits aren't being enforced as expected. I followed the documentation and configured the `appsettings.json` file with a custom policy, but it seems to allow more requests than the specified limits. Hereβs what I have so far: In my `appsettings.json`: ```json { "IpRateLimiting": { "GeneralRules": [ { "Endpoint": "*/api/[controller]", "Limit": 5, "Period": "1s" } ] } } ``` In my `Startup.cs`, I've added the necessary services: ```csharp public void ConfigureServices(IServiceCollection services) { services.AddOptions(); services.AddMemoryCache(); services.Configure<IpRateLimitingOptions>(Configuration.GetSection("IpRateLimiting")); services.AddInMemoryRateLimiting(); services.AddSingleton<IRateLimitPolicyStore, MemoryRateLimitPolicyStore>(); services.AddSingleton<IRateLimitCounterStore, MemoryRateLimitCounterStore>(); services.AddMvc(); } ``` I also made sure to use the middleware: ```csharp public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseIpRateLimiting(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } ``` When I test my API by making six requests to the specified endpoint within one second, I expect to receive a `429 Too Many Requests` response after the fifth request, but instead, every request goes through successfully. I've tried changing the limit and period values, but I still face the same issue. I also checked if the custom policy is being loaded correctly, and it appears to be. Is there something I'm missing in the configuration? Any help would be greatly appreciated! This is part of a larger CLI tool I'm building. This is part of a larger API I'm building. This is part of a larger web app I'm building.