Thanks for watching, here's an example of some code that should work with the latest syntax: app.UseRateLimiter(new RateLimiterOptions() { RejectionStatusCode = 429 } .AddConcurrencyLimiter("Concurrency", options => { options.PermitLimit = 1; }) .AddFixedWindowLimiter("FixedWindow", options => { options.Window = TimeSpan.FromSeconds(5); options.PermitLimit = 10; })); app.MapGet("/rate-limiting", () => { return "Rate limited."; }).RequireRateLimiting("FixedWindow");
Great demo for its clarity on the subject and demonstration of a useful testing tool
Good demonstration of the concept, but the code does not work on the release build of ASP.NET 7. Can you please update and paste the program.cs here?
Thanks for watching, here's an example of some code that should work with the latest syntax:
app.UseRateLimiter(new RateLimiterOptions() { RejectionStatusCode = 429 }
.AddConcurrencyLimiter("Concurrency", options =>
{
options.PermitLimit = 1;
})
.AddFixedWindowLimiter("FixedWindow", options =>
{
options.Window = TimeSpan.FromSeconds(5);
options.PermitLimit = 10;
}));
app.MapGet("/rate-limiting", () => {
return "Rate limited.";
}).RequireRateLimiting("FixedWindow");
Hi, how to Rate Limit a real IP coming from Cloudflare where they send the real IP in a Header name CF-Connecting-IP?
Alex!! Used to watch your vids on pluralsite. Great to see you've got a youtube channel!! Subscribed of course.