ASP.NET MVC 3 Hosting :: How to Upgrade ASP.NET MVC 2 Project to ASP.NET MVC 3

Posted by mbridge on Geeks with Blogs See other posts from Geeks with Blogs or by mbridge
Published on Fri, 18 Feb 2011 00:53:36 GMT Indexed on 2011/02/18 7:26 UTC
Read the original article Hit count: 404

Filed under:
ASP.NET MVC 3 can be installed side by side with ASP.NET MVC 2 on the same computer, which gives you flexibility in choosing when to upgrade an ASP.NET MVC 2 application to ASP.NET MVC 3.
The simplest way to upgrade is to create a new ASP.NET MVC 3 project and copy all the views, controllers, code, and content files from the existing MVC 2 project to the new project and then to update the assembly references in the new project to match the old project. If you have made changes to the Web.config file in the MVC 2 project, you must also merge those changes with the Web.config file in the MVC 3 project.
To manually upgrade an existing ASP.NET MVC 2 application to version 3, do the following:

1. In both Web.config files in the MVC 3 project, globally search and replace the MVC version. Find the following:
System.Web.Mvc, Version=2.0.0.0

Replace it with the following
System.Web.Mvc, Version=3.0.0.0
There are three changes in the root Web.config and four in the Views\Web.config file.
2. In Solution Explorer, delete the reference to System.Web.Mvc (which points to the version 2 DLL). Then add a reference to System.Web.Mvc (v3.0.0.0).
3. In Solution Explorer, right-click the project name and then select Unload Project. Then right-click again and select Edit ProjectName.csproj.
4. Locate the ProjectTypeGuids element and replace {F85E285D-A4E0-4152-9332-AB1D724D3325} with {E53F8FEA-EAE0-44A6-8774-FFD645390401}.
5. Save the changes and then right-click the project and select Reload Project.
6. If the project references any third-party libraries that are compiled using ASP.NET MVC 2, add the following highlighted bindingRedirect element to the Web.config file in the application root under the configuration section:
<runtime>
  <assemblyBinding >
    <dependentAssembly>
      <assemblyIdentity name="System.Web.Mvc"
          publicKeyToken="31bf3856ad364e35"/>
      <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

© Geeks with Blogs or respective owner