ASP.NET Core routing chooses endpoints from route templates, HTTP methods, and constraints—not from C# overload resolution alone. Constraints narrow candidates and should disambiguate shapes, not perform business validation. ```csharp [ApiController] [Route("api/orders")] public sealed class OrdersController : ControllerBase { [HttpGet("{id:guid}")] public IActionResult GetById(Guid id) => Ok(id); [HttpGet("number/{number:int:min(1)}")] public IActionResult GetByNumber(int number) => Ok(number); } ``` Routes such as two `[HttpGet("{value}")]` actions—one taking `int`, another `string`—are ambiguous unless templates include constraints or distinct static segments. C# method signatures do not make the URLs unique. Use clear resource-oriented paths, apply `[FromRoute]`, `[FromQuery]`, or `[FromBody]` when binding could be unclear, and return normal validation errors after routing for domain rules. Integration-test representative and boundary URLs because link generation and endpoint selection are runtime behavior.
Prince Yadav · · 0 likes