We are using the release candidate (RC2) of the Microsoft ASP.NET MVC 3 Model-View-Controller framework for a project we’ve been working on for a while. You can find more info for MVC 3 RC2 here: http://weblogs.asp.net/scottgu/archive/2010/12/10/announcing-asp-net-mvc-3-release-candidate-2.aspx.
Another developer in our organization set up the initial project using Visual Studio 2010 and then checked the project into our Subversion source control repository. I pulled down the project to my local development box to begin working with it and ran into a few issues that I thought I would highlight to help others avoid the same problems.
Problem #1: Project won’t open in Visual Studio
When I initially tried to open the MVC 3 project, I received a variant of the following error message.
Project cannot be opened because its project type (.csproj) is not supported by this version of the application.
Of course, this error occured in Visual Studio because I had not yet downloaded and installed MVC 3 RC2. Doh! All you need to do to address this issue is download the release candidate from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=955d593e-cbd1-4ed1-88eb-02ff79dd74d8.
Problem #2: Cannot run the web application from Visual Studio
After installing MVC 3 RC2, I was able to open the solution and all the projects loaded successfully. I built the solution with no problem and then went to run it without debugging by choosing Ctrl + F5. Wallah! Another issue! This time, I received the following message:
Choosing to wait for a request from another process without enabling ASP.NET debugging results in nothing to debug.
Okay, this is interesting. I’m not really sure what other process request I’m choosing to wait on here. Time to look at ASP.NET debugging properties for the project. Checking the Web settings for the project shows that the ASP.NET debugger is indeed selected. Hmmm…
A closer inspection of the project’s Web settings shows a unique value for the Start Action: “Don’t open a page. Wait for a request from an external application.” This might be the culprit! In fact, after selecting the Start Action of “Specific Page” and leaving the value blank for now, the application launches into my default web browser just fine. Now we’re making some progress!
Problem #3: Directory Listing Denied
Ahhh, the good old familiar error message appears: This Virtual Directory does not allow contents to be listed. Alas, this message rings many a bell and harkens back to a common MVC issue with IIS…lack of a proper script mapping to handle extensionless URLs. This issue is easy to address and there are lots of references on the Internet to handle the issue. In my case, I set up a wildcard script mapping for IIS 5.1 and you can do the same for IIS 6 if you need. IIS 7 and 7.5 should not have any issues with MVC 3.
Refer to the following articles for assistance with setting up MVC 3 on IIS 5.x and 6.
- Using ASP.NET MVC with Different Versions of IIS (C#): http://www.asp.net/mvc/tutorials/using-asp-net-mvc-with-different-versions-of-iis-cs
- ASP.NET MVC on IIS 6 Walkthrough: http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
- ASP.NET MVC 3 Extensionless URLs on IIS 6: http://dotnetslackers.com/ASP_NET/re-428127_ASP_NET_MVC_3_Extensionless_URLs_on_IIS_6.aspx
- Host MVC App on IIS 5.1 (XP Professional): http://blog.davidrenz.com/?p=418
- Cannot Set Wildcard Script Mapping In Xp Pro Iis 5.1: http://thedailyreviewer.com/server/view/cannot-set-wildcard-script-mapping-in-xp-pro-iis-51-109349341
After setting up my wildcard script mapping and launching the project from Visual Studio again, I’m off and running with no errors. Now we’re cooking with gas! So the moral of the story is to ensure you have the MVC 3 RC2 component installed, check the Web project settings to launch a specific page and then ensure the web server knows how to handle MVC requests, especially in an extensionless request configuration.