Route conflict between route handlers (ASP0022)
Ce contenu n’est pas encore disponible dans votre langue.
Key dotnet.api.route-handler-conflict · Severity warning · Category api
ASP.NET Core analyzer ASP0022. Flags two minimal-API route handlers mapped to the same route and method. Requests fail with an ambiguous-match error.
Incorrect
Section titled “Incorrect”app.MapGet("/orders/{id}", (int id) => Find(id));app.MapGet("/orders/{orderId}", (int orderId) => Load(orderId));Correct
Section titled “Correct”app.MapGet("/orders/{id}", (int id) => Find(id));app.MapGet("/orders/{orderId}/lines", (int orderId) => Lines(orderId));