Topic | Value |
---|---|
Id | ASP005 |
Severity | Warning |
Enabled | True |
Category | AspNetCoreAnalyzers.Routing |
Code | AttributeAnalyzer |
Syntax error in parameter.
[HttpGet(""api/orders/id:int}"")]
public IActionResult GetId(int id)
{
return this.Ok(id);
}
In the above code the opening curly brace for the parameter is missing.
Use the code fix of fix the syntax manually. The code in the example should be:
[HttpGet(""api/orders/{id:int}"")]
public IActionResult GetId(int id)
{
return this.Ok(id);
}
Configure the severity per project, for more info see MSDN.
#pragma warning disable ASP005 // Syntax error in parameter
Code violating the rule here
#pragma warning restore ASP005 // Syntax error in parameter
Or put this at the top of the file to disable all instances.
#pragma warning disable ASP005 // Syntax error in parameter
[System.Diagnostics.CodeAnalysis.SuppressMessage("AspNetCoreAnalyzers.Routing",
"ASP005:Syntax error in parameter",
Justification = "Reason...")]