The attribute routing technique is a different way to implement routing in ASP.NET Core. It moves the declaration of routing within the controllers' implementation using attributes to describe the routes in a metaprogramming way:
[Route("api/order")]
[ApiController]
public class OrderController : ControllerBase
{
private readonly IOrderRepository _orderRepository;
public OrderController(IOrderRepository orderRepository)
{
_orderRepository = orderRepository;
}
...
The Route attribute declares the routing template within the controller or the action. The routing attribute is the default approach of the web API template in ASP.NET Core. Another critical thing to notice is that this practice doesn't need any route definition in the Startup class; therefore, app.MapControllers...