rexaliis
rexaliis
CC#
Created by rexaliis on 2/12/2025 in #help
Get associated RateLimiter for the current HttpContext instance
Hello! I'm currently using and Microsoft.AspNetCore.RateLimiting and my question is if is there any way to get the associated RateLimiter instance for the current HttpContext.
app.Use((httpContext, next) =>
{
// Apparently, it is not possible to do this through dependency injection.
var rateLimiter = httpContext.RequestServices.GetService<RateLimiter>();
}
app.Use((httpContext, next) =>
{
// Apparently, it is not possible to do this through dependency injection.
var rateLimiter = httpContext.RequestServices.GetService<RateLimiter>();
}
12 replies