Reputation:
I want to create a controller route to get details for an object with given id.
I know how to create a route like /data?id=15, but I would prefer the route to be /data/15.
How do I do that?
Thanks in advance Paul
Upvotes: 0
Views: 78
Reputation: 19365
[HttpGet]
[Route("data/{id}")]
public IActionResult Get([FromRoute(Name="id")] int id)
{
...
}
Upvotes: 1