The ASP.NET Core team is hard at work making ASP.NET Core better and more performant with each release.

An enhancement in 2.2 is endpoint routing. Here’s how it works.

Endpoint Routing in ASP.NET Core 2.2 Explained

In pre-2.2 versions routing is done at the MVC level. A URL that hits the app is interpreted and mapped to the right controller and action according to the configuration you do in the routing table or with routing attributes. All the work is done in the MVC middleware.

This has a drawback. Because this is at the MVC level other middlewares don’t have a clue at which endpoint the request will arrive.
That is especially a problem with a middleware like the one we have for CORS. You want CORS applied to MVC but also for example to the StaticFiles middleware.

Endpoint Routing in ASP.NET Core 2.2 Explained

With the new solution you add Endpoint routing middleware early on in the pipeline. This is going to pass endpoint information to the rest of the middlewares. When this information arrives at the MVC middleware the controller and action is determined using the endpoint information instead of the URL.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.