Mid ASP.NET Core ASP.NET Core

Routing conventions in Web API (attribute routing, route?

templates)

  • Attribute Routing (Preferred):

[Route("api/products")]

[ApiController]

public class ProductsController : ControllerBase {

[HttpGet("{id}")]

public IActionResult Get(int id) { ... }
}
  • Route Templates:

Use placeholders like {id}, constraints like {id:int}.

You can also define route prefixes at controller level and use relative routes

in actions.

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details