Ir al contenido

Attribute on a method a route handler calls (ASP0005)

Esta página aún no está disponible en tu idioma.

Key dotnet.api.route-handler-attribute-on-called-method · Severity warning · Category api

ASP.NET Core analyzer ASP0005. Flags an attribute such as [Authorize] placed on a method that a route handler lambda merely calls - the attribute only works on the handler itself, so it is silently ignored.

app.MapGet("/admin", () => Admin());
[Authorize(Roles = "Admin")]
static string Admin() => "ok";
app.MapGet("/admin", [Authorize(Roles = "Admin")] () => Admin());
static string Admin() => "ok";