Error Loading MVC 3 Project after MVC 4 is Installed or in VS 2011

Since installing the ASP.net MVC 4 Beta, it has happened to me a few times that MVC 3 websites will not load when the solution is loaded into VS 2010 (I have also read about this happening with VS 2011).

You can fix this by doing the following:

  1. In the Solution Explorer, right click on the project that wont load and click on “Edit [ProjectName].csproj”. This will open up the project definition file in VS. You can also edit this manually using your favorite text editor, opening the file through Windows Exporer.
  2. Find the line in the file that starts with ProjectTypeGuids and remove the entry “{E53F8FEA-EAE0-44A6-8774-FFD645390401}” from the list (this is code that tells Visual Studio that it is an MVC 3 project – for some reason, including this in the project file after installing MVC 4 messes things up).
  3. Save the .csproj. file and [Reload] the project through the Right Click menu in Solution Explorer.

The project should now load properly (if the MVC project has been the startup project for the solution, you may have to reset this as well).

I Love it When Technical Book Authors Have a Sense of Humor

I am going through Pro ASP.NET MVC 3 Framework by Adam Freeman and Steven Sanderson (@StevenSanderson) (Apress). Enjoying it so far – good technical writing, good level of detail mixed with useful examples of different implementation options.

And most importantly, they have a good sense of humor. From Page 381 (my highlights):

Quote from Pro ASP.NET MVC 3 (Sanderson & Freeman), page 381

If you don’t want to click on the link, they are talking about best practices for url schemas using MVC, and give an example of a link to Amazon as something not to do (I realize the irony of my linking to Amazon above). They then include in an aside:

Note To be very clear, we have only the highest respect for Amazon, who sells more of our books than everyone else combined. We know for a fact that each and every member of the Amazon team is a strikingly intelligent and beautiful person. Not one of them would be so petty as to stop selling our books over something so minor as criticism of their URL format. We love amazon. We adore Amazon. We just wish they would fix their URLs

.Another good one: The authors are talking about using MVC to create a REST API, where the same action name in a given controller can be overridden to handle HTTP Get/Post/Delete requests (page 476, my emphasis):

Now each StaffMember entity in our application can be uniquely addressed using a URL of the form Staff/123, and a client can use the GET, POST, and DELETE HTTP methods to perform operations on those addresses. This is called a RESTful API, except by people who claim to be experts in REST, who will tell you that nothing is truly RESTful except their own code. (We joke—sort of).

Gotta love it.