This is more a PSA for other users of Radzen.
I’ve been knocking my head against the wall regarding the following error:
Program.cs(218,21): error CS0103: The name 'http' does not exist in the current context
The line, 218 pointed to something completely unrelated to the error. What caused the error was this block of code in my Program.cs:
builder.Services.AddRateLimiter(options =>
{
options.GlobalLimiter = PartitionedRateLimiter.Create<HttpContext, string>(http =>
{
// Partition per token or per IP if unauthenticated
var token = http.Request.Headers["X-Api-Key"].ToString();
if (string.IsNullOrEmpty(token))
{
token = http.Request.Query["k"].ToString();
}
if (string.IsNullOrEmpty(token))
{
token = http.Connection.RemoteIpAddress?.ToString() ?? "anon";
}
return RateLimitPartition.GetTokenBucketLimiter(
token,
_ => new TokenBucketRateLimiterOptions
{
TokenLimit = 60, // burst
TokensPerPeriod = 60,
ReplenishmentPeriod = TimeSpan.FromMinutes(1),
QueueLimit = 0,
AutoReplenishment = true,
}
);
});
});
Guarding it with
#if !RADZEN
#endif
fixed the issue.