dotnet / dotnet/aspnetcore

Allow non-attribute routing for ApiController

Open
#43,192 5 comments 0 reactions 0 assignees View on GitHub
area-mvc Needs: Attention :wave:
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I am trying to use non-attribute routing for my `ApiController` but when I try to `UseEndpoints()` throws the exception:

> System.InvalidOperationException: 'Action 'Controllers.Api.WeatherForecastController.Get' does not have an attribute route. Action methods on controllers annotated with ApiControllerAttribute must be attribute routed.'

### Describe the solution you'd like

`ApiController`s should support non-attribute routing.

### Additional context

It's regularly stated that attribute routing becomes a requirement when a controller is an `ApiController`. What I don't understand is *why*. It seems completely arbitrary. Can't it be opened up to non-attribute routing, or does this cause some technical problem?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.