The URL routing engine in ASP.NET can be used to both map
incoming URLs to code handlers, as well as be used to programmatically generate
outgoing URLs using the same mapping registration logic.
For example, above when we mapped the /products/{category}
URL we gave it a “friendly name” of “products-browse”. This allows us to
now also use the new Page.GetRouteUrl() helper method to lookup the route
within the URL routing system, optionally specify parameters to it, and then retrieve
an actual URL that it maps back to. For example, the below code would
retrieve a URL value of “/products/software”:
Figure 5
You can access the above helper method within either your
code-behind file or within your .aspx markup.
There is also now a Response.RedirectToRoute() set of
methods that you can use to redirect users to a route (regardless of whether it
is a MVC or Web Forms handled one) and optionally pass parameters to it.