DotNetAnalyzers / AspNetCoreAnalyzers

MIT License
62 stars 4 forks source link

Don't name routes reserved routing names. #21

Open JohanLarsson opened 5 years ago

JohanLarsson commented 5 years ago

The following keywords are reserved names and can't be used as route names or parameters:

  • [ ] action
  • [ ] area
  • [ ] controller
  • [ ] handler
  • [ ] page

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-2.2#reserved-routing-names

[HttpGet("api/values/{id}", Name = ↓"area")]
public ActionResult<string> Get(string id)
{
    return $"'{id.ToString()}'";
}
JohanLarsson commented 5 years ago

37