From the course: ASP.NET MVC: HTTP Request Life Cycle
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Explore attribute routing
From the course: ASP.NET MVC: HTTP Request Life Cycle
Explore attribute routing
- [Instructor] In ASP.NET MVC five, attribute routing was introduced which allows us to define routes directly on controllers and actions. Having route definitions that are in close proximity to actions is easier and more flexible than convention based routing. Let's get into the code and see how it works. Open up the route config file in the Roux Academy project. We had used convention based routing before to map routes to the route table. With attribute routing, we'll still be populating the route table but not in this configuration class. We do have to enable routing first with a call to routes and MapMvcAttributeRoutes. Notice how we did this during route configuration and that we can have both convention based and attribute routing in the same application. We've registered attribute routing first so these routes will have a higher order in the route table. They'll be evaluated by the URL routing module first before these conventional routes. Take a look at this custom route we…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.