Answer
Endpoint Routing decouples route matching from endpoint execution.
UseRouting()runs early, matches the request to an endpoint, and attaches endpoint metadata.- Middleware such as authentication and authorization can inspect endpoint metadata.
UseEndpoints()executes the matched endpoint (controller, Razor Page, minimal API).
This improves performance, centralizes routing, and makes it easier to apply policies based on endpoint metadata.