Monday, May 16, 2011

Visual Studio: ASP.NET MVC, Flip quickly through your controllers and views

This tip is specifically for those writing ASP.NET MVC applications using Visual Studio

As your MVC application grows, the number of views and controllers can grow pretty quickly and ctrl+tabbing through them gets pretty painful, sometimes only to discover that you don't have *that* view open, so you need to go find it. That's where this tip comes in, if you right click on your controller, there's a menu option to go to the view, likewise, if you are in the view and right click there's a menu option to go to the controller, now, if you are a mouse guy, this is enough for you, you can stop reading now, but there's a quicker way, you can assign a shortcut key to those options

Go to Tools, Options, Environment (first option), keyboard, and type "GoToView" (without the quotes) and assign the shortcut you want, chose one that is not being used, or one of a feature you don't use (there are  millions of those), for this type of thing that I do a lot, I like using keys that are easily accessible, put that F1 key to good use!!, do the same thing for the "GoToController"

Click OK and you're ready to roll, go to your controller and press your shortcut, you'll be flipping through your views and controllers like there's no tomorrow!

You're welcome J