Convert ASP.NET MVC 3 project to MVC 4

What steps should be taken to safely upgrade an existing ASP.NET MVC 3 project to the latest ASP.NET MVC 4 Developer Preview ?

+47
asp.net-mvc asp.net-mvc-3 asp.net-mvc-4
Jan 13 '12 at 15:55
source share
4 answers

The main change is to update the corresponding links to the latest version (4.0 / 2.0). You need to update your web configuration files to update the version of the following namespaces.

  • System.Web.Mvc (Change to 4.0.0.0)
  • System.Web.Webpages (Change to 2.0.0.0)
  • System.Web.Helpers (Change to 2.0.0.0)
  • System.Web.WebPages.Razor (Change to 2.0.0.0)

You also need to update the root level web configuration file to have these appsettings entries.

<appSettings> <add key="webpages:Version" value="2.0.0.0" /> <add key="PreserveLoginUrl" value="true" /> </appSettings> 

Then you need to update the DLLs specified in the project. Remove the existing link to MVC3 dll and add MVC4 (use the nuget package manager for this)

This link handles all aspects of the conversion. Contact him as necessary.

+41
Jan 13 '12 at 16:00
source share

Follow the official steps posted here:

http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806

Note. These steps cover the official release, not the developer preview.

+16
Apr 08 '13 at 17:18
source share

Better yet, use the auto-update tool:

https://www.nuget.org/packages/UpgradeMvc3ToMvc4

+5
Jul 30 '13 at 0:47
source share

It is best to install the MVC4 installation from the platform installer. Then follow the steps on the official asp.net/mvc/mvc4 page. If you follow the Shyju instructions (only), this will not work.

When you are done with the official instructions, look in your Views directory and you can find another web.config with another link to the MVC assembly and several others for the razor. You also want to change the versions of these lines. Basically replace every 3.0.0.0 you find for 4.0.0.0 and 1.0.0.0 for 2.0.0.0

IF YOU DO NOT MAKE THIS LAST CHANGE, YOU MAY END AN ERROR BY THE NEXT QUESTION

Look at the included DLL and make sure that they are designed for the correct versions.

+4
Mar 21 '13 at 17:26
source share



All Articles