Skip to content

MapToApiVersion on a controller action prevents other actions from executing #884

Closed
@overdunne

Description

@overdunne

If I have an action [HttpGet("{id}")], and [MapToApiVersion("1.5")], then that method will be invoked instead of another method with a different route.

For the controller below, if I invoke http://localhost:5167/v1.5/Message/Test, then the Id method instead is run. If I remove the MapToApiVersion attribute, then it behaves as expected.

[Route("v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.5")]
[ApiVersion("1.6")]
public class MessageController
{
    [HttpGet("Test")]
    public string Get()
    {
        return "Test";
    }

    [HttpGet("{id}")]
    [MapToApiVersion("1.5")]
    public string Id(string id)
    {
        return "You asked for: " + id;
    }
}

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions