Endpoint Routing in ASP.NET Core 2.2 Explained

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.

avatar
Roland Guijthttps://rolandguijt.com/
Roland is a Microsoft MVP and ASP.NET Insider enjoying a constant curiosity around new techniques in software development. His focus is on all things .NET, browser technologies and development for the enterprise. As a long-time trainer, he leads many courses on these topics and speaks about them at international conferences. He is also a well-known Pluralsight author. The word that comes to mind when he thinks about software development is passion! Feel free to contact him on Twitter!

Related Articles

Leave a Reply

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

Stay Connected

6,065FollowersFollow
5,929FollowersFollow

Subscribe to our newsletter

To be updated with all the latest news, offers and special announcements.

Latest Articles