As mentioned at the end of Chapter 9, Routing is simple to learn yet challenging to master. Here are a few advanced tips Phil recommends to simplify some otherwise tricky routing scenarios.
In Chapter 9, we mentioned the RouteMagic project, which is an open source project available on CodePlex at http://routemagic.codeplex.com/.
This project is also available as a NuGet package appropriately named RouteMagic. RouteMagic is a pet project of Phil Haack, one of the authors of this book, and provides useful extensions to ASP.NET Routing that go above and beyond what's included “in the box.”
One useful extension included in the RouteMagic package is support for redirect routes. As noted usability expert Jakob Nielsen has recommended, “persistent URLs don't change,” and this redirect routes will help you support that.
One of the benefits of routing is that you can change your URL structure all you want during development by manipulating your routes. When you do so, all the URLs in your site are updated automatically to be correct, which is a nice feature. But once you deploy your site to the public, this feature becomes a detriment as others start to link to the URLs you've deployed. You don't want to change a route at this point and break every incoming URL.
Unless…you properly redirect. After installing RouteMagic, you'll be ...