Skip to content

Latest commit

 

History

History
56 lines (42 loc) · 1.37 KB

ASP011.md

File metadata and controls

56 lines (42 loc) · 1.37 KB

ASP011

Route parameter appears more than once

Topic Value
Id ASP011
Severity Warning
Enabled True
Category AspNetCoreAnalyzers.Routing
Code AttributeAnalyzer

Description

Route parameter appears more than once.

Motivation

[HttpGet(""api/{id}/{id}"")]
public IActionResult GetId(string id)
{
    return this.Ok(id);
}

How to fix violations

Have the parameter only in one place.

Configure severity

Via ruleset file.

Configure the severity per project, for more info see MSDN.

Via #pragma directive.

#pragma warning disable ASP011 // Route parameter appears more than once
Code violating the rule here
#pragma warning restore ASP011 // Route parameter appears more than once

Or put this at the top of the file to disable all instances.

#pragma warning disable ASP011 // Route parameter appears more than once

Via attribute [SuppressMessage].

[System.Diagnostics.CodeAnalysis.SuppressMessage("AspNetCoreAnalyzers.Routing", 
    "ASP011:Route parameter appears more than once", 
    Justification = "Reason...")]