Under the Hood: How Routes Tie Your URL to an Action
This section provides a peek under the hood to get a detailed understanding of how these pieces tie together. This will give you a better picture of where the dividing line is between routing and MVC.
One common misconception is that routing is just a feature of ASP.NET MVC. During early previews of ASP.NET MVC 1.0, this was true, but it quickly became apparent that Routing was a useful feature in its own right beyond ASP.NET MVC. For example, the ASP.NET Dynamic Data team was also interested in using Routing. At that point, Routing became a more general-purpose feature that had neither internal knowledge of nor a dependency on MVC.
To better understand how routing fits into the ASP.NET request pipeline, let's look at the steps involved in routing a request.
The discussion here focuses on routing for IIS 7 (and above) Integrated Mode. There are some slight differences when using routing with IIS 7 Classic Mode or IIS 6. When using the Visual Studio built-in web server, the behavior is very similar to the IIS 7 Integrated Mode.
The High-Level Request Routing Pipeline
The routing pipeline consists of the following high-level steps:
1. The UrlRoutingModule attempts to match the current request with the routes registered in the RouteTable.
2. If a route matches, the Routing module grabs the IRouteHandler from that route.
3. The ...
Get Professional ASP.NET MVC 3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.