Skip to content

Latest commit

 

History

History
65 lines (50 loc) · 1.34 KB

ASP009.md

File metadata and controls

65 lines (50 loc) · 1.34 KB

ASP009

Use kebab-cased urls

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

Description

Use kebab-cased urls. Note that this is a breaking change.

Motivation

[HttpGet(""api/TwoWords"")]
public IActionResult GetId()
{
    ...
}

How to fix violations

[HttpGet(""api/two-words"")]
public IActionResult GetId()
{
    ...
}

Use kebab-cased urls.

Configure severity

Via ruleset file.

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

Via #pragma directive.

#pragma warning disable ASP009 // Use kebab-cased urls
Code violating the rule here
#pragma warning restore ASP009 // Use kebab-cased urls

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

#pragma warning disable ASP009 // Use kebab-cased urls

Via attribute [SuppressMessage].

[System.Diagnostics.CodeAnalysis.SuppressMessage("AspNetCoreAnalyzers.Routing", 
    "ASP009:Use kebab-cased urls", 
    Justification = "Reason...")]