So, I'm absolutely loving ASP.NET MVC. I started with version 2, and I'm loving 3 even more - especially the Razor view engine, and all the new validation goodness. Deploying a staging site over the weekend, though, I ran into an odd error with my Razor views that I am kicking myself for not immediately connecting to errors with the WebForms view engine I used to get.
The name 'model' does not exist in the current context
WebForms view engine users will see something like this, where dynamic could instead be any custom model your application might have:
Could not load type 'System.Web.Mvc.ViewPage<dynamic>'
I'll get to the quick and easy part, and end this embarrassing episode entirely: The most likely cause of these errors is that you forgot to upload the web.config file in the /Views directory to the server, while basically getting most of the other files needed for MVC.
I'm not sure how common this situation will be for folks; I use a particular deployment strategy with some types of sites that leads to this happening once on every new MVC site I deploy this way, but I've not seen anyone else posting about this specific cause and effect. Essentially, I deploy these sites via FTPS, and I use the web.config transforms capability in Visual Studio to produce differing configurations for my development use and the staging (or even production) environments to which I'm deploying.
I purposefully, therefore, leave out web.config files in my FTP client (FileZilla) from display at all, by default. I upload the initial web.config in the root of the site from the appropriate location VS has saved the transformed version... and I almost always forget the one located in the /Views folder. This web.config does things like prevent loading the View files directly from the browser, setting the base Page or Control object for sub-items (the cause of the WebForms error) and setting the default namespaces being used in Razor views (the cause of the Razor error).
Hopefully, the act of posting this will appease the Internet Karma Gods, who will now allow me to 1) remember to copy this file, too and 2) if I still forget, remember to check this first before checking things like if MVC is installed correctly, etc, etc...