Ir al contenido

Route parameter and argument optionality do not match (ASP0007)

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

Key dotnet.api.route-optionality-mismatch · Severity warning · Category api

ASP.NET Core analyzer ASP0007. Flags a route parameter declared optional ({id?}) whose handler argument is not nullable, or the reverse. The route matches requests the handler cannot bind.

app.MapGet("/orders/{page?}", (int page) => List(page));
app.MapGet("/orders/{page?}", (int? page) => List(page ?? 1));