How to make valid route for {id}/visit?

Viewed 115

I am new at asp.core , so I try to make valid route to {id}/visits

My code:

[Produces("application/json")]
[Route("/Users")]
public class UserController 
{
    [HttpGet]
    [Route("{id}/visits")]
    public async Task<IActionResult> GetUser([FromRoute] long id)
    {
        throw new NotImplementedException()
    }
}

But, at route {id} generated method the same:

// GET: /Users/5
[HttpGet("{id}")]
public async Task<IActionResult> GetUser([FromRoute] long id)
{
    return Ok(user);
}

How to make route /Users/5/visits nethod?
What parameters at GetUser should I add?

1 Answers
Related