ASP0022: Route conflict detected between route handlers
Value | |
---|---|
Rule ID | ASP0022 |
Category | Usage |
Fix is breaking or non-breaking | Non-breaking |
Cause
An HTTP request matches multiple routes, resulting in an ambiguous match error.
Rule description
This diagnostic is emitted when a route conflict is detected.
How to fix violations
To fix a violation of this rule, change the route's pattern, HTTP method, or route constraints.
When to suppress warnings
Do not suppress a warning from this rule.
Notes
ASP0023 warns on route conflicts in ASP.NET Core MVC apps, this analyzer warns on route conflicts in minimal API apps.
This analyzer is intentionally conservative about duplicate routes it reports to avoid false positives:
- The analyzer only reports duplicate routes declared in the same code block in a method. Duplicate routes in different branches of an
if
statement aren't reported because the analyzer can't statically determine which will be used at runtime. - The analyzer only reports duplicate routes with known metadata. Unknown methods called on a route handler might add new metadata that is then used to customize how the route is matched.
Colaborați cu noi pe GitHub
Sursa pentru acest conținut poate fi găsită pe GitHub, unde puteți, de asemenea, să creați și să consultați probleme și solicitări de tragere. Pentru mai multe informații, consultați ghidul nostru pentru colaboratori.
Feedback
https://aka.ms/ContentUserFeedback.
În curând: Pe parcursul anului 2024, vom elimina treptat Probleme legate de GitHub ca mecanism de feedback pentru conținut și îl vom înlocui cu un nou sistem de feedback. Pentru mai multe informații, consultați:Trimiteți și vizualizați feedback pentru