Skip to content

Determine the used route when multiple MVC routes are assigned to one action method. #4020

@ghost

Description

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

I have the following code:

[Route("item/up/{id}")]
[Route("item/down/{id}")]
public IActionResult Move([FromRoute]string action, [FromRoute]int id)
{
}

Consider /item/up/155. The problem is that when I check the value of action, then it does not contain the value up, but the value Move.

It may be by design, but it seems odd to me as the controller name is not transformed into ItemController.

Describe the solution you'd like

I would like action to have the value of the actual route parameter, not the value of the action method.

Describe alternatives you've considered

I can parse Request.Path.Value (="/item/up/155"), but I'd prefer not to as I would like to keep things simple.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions