Zum Inhalt springen

Route parameter and argument optionality do not match (ASP0007)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

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));