In Chapter 3, Introducing ASP.NET MVC 4, we learned that the ASP.NET MVC 4 framework makes the determination of which controller should handle an incoming request by looking at the routes added to our route table. In actuality, it uses the route table for more than matching incoming routes. It also uses the route table to determine how to generate URLs using the HTML helpers ActionLink
and RouteLink
. When determining how to route an incoming request or generate a link, the runtime selects the first matching route from the route table.
Currently, our RouteConfig
class registers a single route named Default
:
routes.MapRoute(name: "Default",url: "{controller}/{action}/{id}",defaults: new { controller = "Recipe", action = "Index", id = UrlParameter.Optional } );
This route is sufficient for most apps where users are simply creating objects and then retrieving them by id
. However, one of our requirements is the ability to allow users of our app to filter the type of recipe by...