ASP.NET Core › Controllers vs Minimal APIs
How does route-to-code discoverability differ between controllers' attribute-based routing and minimal APIs' explicit registration, and what are the trade-offs for large codebases?
IntermediateAnswer
Controllers' attribute-based routing ([HttpGet("products/{id}")] on a method) co-locates the route definition directly with its implementation, making it easy to find by opening the relevant controller file, but harder to get a bird's-eye view of an entire API's route surface without scanning every controller. Minimal APIs' explicit registration in Program.cs (or grouped extension methods) provides better at-a-glance visibility of the full route table in one place, but requires navigating away from the handler implementation itself (if defined elsewhere) to see its route.
// Controllers: route and implementation co-located, but scattered across many files
[HttpGet("{id}")]
public IActionResult Get(int id) => Ok(_service.GetById(id)); // route right here
// Minimal APIs: centralized route table, implementation possibly in a separate file
app.MapGet("/products/{id}", ProductHandlers.GetById); // route here, logic elsewhereReal-world example A new team member onboarding to a minimal-API-based project quickly understands the full route surface by skimming a handful of MapXEndpoints() extension method files, compared to a controller-based sibling project requiring them to open dozens of individual controller files to build the same mental map.