I was looking for information about attribute-based routing and found that there are two different attributes one can use: HttpGet("")
and Route("")
. However, I can't find any information about what the difference is between them.
Does one of them exist in order to support old ASP versions, or this there a different reason?
P.S. My code might not be totally correct, because I have just started to learn ASP. If something is not clear, I will try to explain.
public class MyController : Controller
{
// APPROACH 1
[Route("api/books")]
[HttpGet]
public async List<Book> GetBooks()
{
// Implementation
}
// APPROACH 2
[HttpGet("api/books")]
public async List<Book> GetBooks()
{
// Implementation
}
}