"You're gonna drown tomorrow if you cry too many tears for yesterday" (Townes Van Zandt)

Upgrading MVC Beta project to RC1

Page 1

As I mentioned in my previous post, I started to re-write this blogging site using new technologies and concepts I’ve learned in the past 2 years. One of the changes will be to use ASP.NET MVC as the web framework instead of the classic WebForms model.

I created my application using the beta release, but as we all know by now, RC1 has been released last week. Now, lucky for me, I haven’t developed anything crucial yet in the MVC project. I only played around yet with routing and was just starting to look into Views when I decided to “upgrade”.
After the installation of the RC1 framework, I wanted to play around with strong typed Views but received following error page...

p>

One of the new things in RC1 is that the views now are created without code behind files (which I love so much), and allows you to use generics in the Inherits attribute like below.

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MyLibrary.MyObject>"%>

Obviously, something went wrong and most likely it was, or looking still at the beta dll’s, or I’m just missing an inherit or reference somewhere.
I tried quite a lot of things, including manually uninstalling all mvc frameworks, checking the gac with gacutil, changing some registries... without success. You can follow the forum entry I started on asp.net.

Best thing was that when I created a new MVC project using RC1, everything worked fine. Because I hadn’t developed that much at all yet, it would have been no problem to create it from scratch again. But, as always, there had to be a solution to the problem and I would find it, and I did :D:D

Solution

I compared the web.config files of a new created project and my old beta project, but they all seemed to be ok. But then someone pointed out that there was also a web.config file in the View folder of your MVC project. Right on. Comparing these two gave me the following.

<pages

    validateRequest="false">

</pages>

The original code

...

<pages

  validateRequest="false"

  pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"

  pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"

  userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

  <controls>

    <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />

  </controls>

</pages>

...

The new web.config content

As you can see, the pages section of the new created project contains extra attributes, all linked to the correct classes and dll’s. Copy/Paste this into my existing file made the page run as it should ;)

More Problems

But then, after solving this, there occurred a second problem. When opening the view in the Visual Studio designer, the IDE just shuts down. No warning, no nothing... just gone. This also was mentioned in the forum thread I started earlier by somebody else, and he pointed me to this thread on StackOverflow.

What I did was uninstalling the PowerCommands for Visual Studio 2008 that I had installed, and the error went away. I’m now perfectly able to create strong typed views, receive the intellisence that is provided in RC1 and all this while still using my “old” project. I don’t have the PowerCommands anymore, but so far I’m not missing it yet :D

Though, some strange behaviour still occurs. For example, System.Web.Mvc does NOT appear anymore in the “add reference” dialog of Visual Studio. Though, gacutil confirms that it IS installed in the GAC. I guess maybe something wrong with the msi file or again something I did wrong. Also, creating and using a new project with RC1 CAN be done even if you have PowerCommands installed.