Should You Use UseRouting() or MapGet() First?

Learn why UseRouting() must always come before MapGet() in ASP.NET Core and how the middleware order impacts your request pipeline.

September 23, 2025 · 3 min

Enhance ASP.NET Core Routes with Custom Constraints

TL;DR Learn how to build custom route constraints in ASP.NET Core using IRouteConstraint. Use them to validate route parameters (like ensuring only alphabets or specific patterns), inject services like IUserService, and simplify controller logic. Bonus: works with minimal APIs, conventional routes, and supports DI in constraints via the new ASP.NET Core routing system. URL routing is a fundamental part of ASP.NET Core applications, determining how incoming requests are mapped to controller actions. While the framework provides numerous built-in route constraints like int, bool, and guid, there are situations where you need more sophisticated validation rules for your URL parameters. This is where custom route constraints become invaluable. ...

June 20, 2025 · Last modified: September 20, 2025 · 8 min
×