If you have a
.aspxfile open in Visual Studio 2008, and focus is on that tab, then when you run your ASP.Net MVC application
ViewDatawill be null. Any breakpoints you set in your source won't be hit either.
The solution is to set focus on a tab containing a
.csfile and then run the app.
I don't see what the connection is between which source tabs have focus and which bit of code is executed (or not), but there it is. If you're aware of an explanation or fix for this baffling behaviour, please do chime in.
Turns out the fix for this is to explicitly set a startup url at Project properties -> Web -> Start Action -> Specific Page. Thanks to Ajey for the tip.