A question about routing attribute
-
Hi, What does [Route("id:guid")] mean in the following code? (This code is a part of an API)
[HttpGet]
[Route("id:guid")]
[ActionName("GetCard")]
public async Task GetCard([FromRoute]Guid id)
{
var card = await context.Cards.FirstOrDefaultAsync(x => x.Id == id);
if(card != null)
{
return Ok(card);
}
return NotFound("Card not found");
} -
Hi, What does [Route("id:guid")] mean in the following code? (This code is a part of an API)
[HttpGet]
[Route("id:guid")]
[ActionName("GetCard")]
public async Task GetCard([FromRoute]Guid id)
{
var card = await context.Cards.FirstOrDefaultAsync(x => x.Id == id);
if(card != null)
{
return Ok(card);
}
return NotFound("Card not found");
} -
This is the way to route you have to go through the website: Routing in ASP.NET Core | Microsoft Docs[^]