Topic | Value |
---|---|
Id | ASP013 |
Severity | Warning |
Enabled | True |
Category | AspNetCoreAnalyzers.Routing |
Code | AttributeAnalyzer |
Name the controller to match the route.
For keeping the controller name in sync with the route:
[Route(""api/sample-data"")]
[ApiController]
public class WrongName : Controller
{
}
Change the name in the above to:
[Route(""api/sample-data"")]
[ApiController]
public class SampleDataController : Controller
{
}
Configure the severity per project, for more info see MSDN.
#pragma warning disable ASP013 // Name the controller to match the route
Code violating the rule here
#pragma warning restore ASP013 // Name the controller to match the route
Or put this at the top of the file to disable all instances.
#pragma warning disable ASP013 // Name the controller to match the route
[System.Diagnostics.CodeAnalysis.SuppressMessage("AspNetCoreAnalyzers.Routing",
"ASP013:Name the controller to match the route",
Justification = "Reason...")]