I was teaching an ASP.NET MVC class just before Christmas, and was forcefully reminded of two things – 1) ASP.NET MVC Routing can be really tricky to get your head around, and 2) a surprising number of people still aren’t familiar with NuGets and don’t take advantage of them.
So this blog post is designed to kill two birds with one stone. I’m going to introduce NuGets and show you one in particular that helps you become familiar with the routing engine.
First up: what is NuGet?
NuGet is a mechanism to make the downloading and installing of useful .NET libraries transparent and easy. It comes with Visual Studio – but you may have an old version and need to uninstall it and install the latest version before you begin. Once you’ve done so, it’s very easy to install new packages. Here’s how you do it…
1. Open a project to which you want to add a NuGet (in this case, the routing debugger).
2. Go to Tools | Library Package Manager | Manage NuGet Packages
3. That brings up the NuGet dialog.
4. You then search for the NuGet you’re after (in this case, the route debugger by Phil Haacked) and then click on the Install button once you’ve found it.
5. Now all you have to do is use it. In this case, that means running your application and using the useful debugging utility to see which of your routes matches the address in the browser. A great way to learn more about routes and test whether your routes really do what you think they’re doing…. (I’d advise using this one on a learn-routing project rather than a real site, by the way).
NuGets – they’re easy to use, and there’s one out there that’s just what you need.
For other related information, check out these courses from Learning Tree: