Upgrading an ASP.NET MVC 2 Project to ASP.NET MVC 3

Resources:
ASP.NET MVC 3 Preview 1 – MVC-3-Preview-1-Release-Notes.doc
ASP.NET MVC Preview 3 Release – ScottGu
ASP.NET MVC 3 Preview 1 Released : Channel 9 Video and Hanselminutes Podcast 224, Oh My!
ASP.NET MVC 3 Preview 1 Released – Phil Haack

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:
1
System.Web.Mvc, Version=2.0.0.0

Replace it with the following

1
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.

  1. 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).
  2. In Solution Explorer, right-click the project name and then select Unload Project. Then right-click again and select Edit ProjectName.csproj.
  3. Locate the ProjectTypeGuids element and replace {F85E285D-A4E0-4152-9332-AB1D724D3325} with {E53F8FEA-EAE0-44A6-8774-FFD645390401}.
  4. Save the changes and then right-click the project and select Reload Project.
  5. 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:
1
2
3
4
5
6
7
8
9
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="System.Web.Mvc"
          publicKeyToken="31bf3856ad364e35"/>
      <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

<:footer>This entry was posted in ASP.NET, C#, MVC and tagged , . Bookmark the permalink.

http://blog.devlpr.net/2010/07/27/upgrading-an-asp-net-mvc-2-project-to-asp-net-mvc-3/

http://stackoverflow.com/questions/1836410/can-i-develop-for-net-framework-4-in-visual-studio-2008

http://weblogs.asp.net/leftslipper/

http://mattsieker.com/index.php/2010/11/21/converting-asp-net-mvc2-project-to-mvc3/

http://msdn.microsoft.com/en-us/library/ms247046.aspx

http://blogs.msdn.com/b/marcinon/archive/2011/01/13/mvc-3-project-upgrade-tool.aspx

About eagle081183

Passionate, Loyal
This entry was posted in ASP.NET MVC, C#. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s