O'Reilly logo

Mastering ASP.NET Web API by Malendra Hurbuns, Mithun Pattankar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Routing constraints

ASP.NET Core, either as an MVC or a web API application, supports both attribute and centralized routing mechanism. The routes can either be directly set on the controller and actions using the Route attribute, or by creating and mapping all the routes in one place.

We have seen that different route templates can be created with or without route parameters. When route templates have parameters in them, it helps to build excellent routing patterns. But the presence of route parameters can cause issues too; let's see an example for this:

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { var routeBuilder = new RouteBuilder(app); routeBuilder.MapGet("employee/{id}", context ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required