Introduction to Routing
Routing within the ASP.NET MVC framework serves two main purposes:
The above two items only describe what Routing does in the context of an ASP.NET MVC application. Later in this chapter we'll dig deeper and uncover additional Routing features available for ASP.NET.
Comparing Routing to URL Rewriting
To better understand Routing, many developers compare it to URL Rewriting. After all, both approaches are useful in creating a separation between the incoming URL and what ends up handling the request and both of these techniques can be used to create pretty URLs for Search Engine Optimization (SEO) purposes.
The key difference is that URL Rewriting is focused on mapping one URL to another URL. For example, URL Rewriting is often used for mapping old sets of URLs to a new set of URLs. Contrast that to routing which is focused on mapping a URL to a resource.
You might say that routing embodies a resource-centric view of URLs. In this case, the URL represents a resource (not necessarily a page) on the Web. With ASP.NET Routing, this resource is a piece of code that executes when the incoming request matches the route. The route determines how the request is dispatched based on the characteristics of the URL—it doesn't rewrite the URL.
Another key difference is that ...