Friday, August 14, 2009

VS 2010 and ASP.Net MVC Error

The view at '~/Views/Home/Index.aspx' must derive from ViewPage, ViewPage<TViewData>, ViewUserControl, or ViewUserControl<TViewData>


You have installed the brand new Visual Studio 2010 Beta 1 and ASP.Net MVC 1 and try it out. Then bang, you get this error.



But its easily fixed.

Step 1: Open your project file (*.csproj) and change the below line.

before:
<Reference Include="System.Web.Mvc, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

after:
<Reference Include="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">


Step 2: In your web.config file and change the below line

before:
<add assembly="System.Web.Mvc, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

after:
<add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

Re-build and run, and it hopefully works!

Happy Coding!

ravi