Upgrade Project MVC 2 to MVC 4



Use BC to do this. You can just compare to codelibmvc. 

Compare the web config, make sure the assembly binding looks like this:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="" newVersion="" />

Also, in site.csproj - make sure this is good:

and this line says ver 4
<Reference Include="System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

Also, you need to get these files from the /bin folder




1) Install Visual Studio 2012
2) Project is up-to-date in svn (commit or update project)
3) Open project .sln in Visual Studio 2010
4) Upgrade references
a) Delete system.web.mvc from Site, SavvyMVC and SavvyCore (savvycore project might not have this reference)
b) Add back in the system.web.mvc ( version there might be three of them) reference to Site and SavvyMVC
c) Set Copy Local to True for system.web.mvc in Site
5) Search for "system.web.mvc" in web.configs that have a version number, change any version numbers from to
6) Find "bindingRedirect" in Web.config, change oldVersion to and newVersion to
7) Close the solution
8) Open Site.csproj in notepad or any other text editing program
9) Under ProjectTypeGuids change {F85E285D-A4E0-4152-9332-AB1D724D3325} to {E3E379DF-F4C6-4180-9B81-6769533ABE47}
10) Find another site already upgraded to MVC 4 and copy these dlls from the bin folder to your own projects bin folder.
(microsoft.web.infrastucture, microsoft.web. webpages.deployments, microsoft.web. webpages.dll, microsoft.web. razor.dll, microsoft.web. webpages.razor.xml)
11) Open .sln with Visual Studio 2012 (by doing right click open with), ignore the upgrade report that is shown.
12) Build and test the solution has no build errors
13) If error is httpantiforgerytoken, diff error.cs to codelib and get new version that doesnt use that code.



1) Add the Beweb menu to Visual Studio 2012, get the import settings from I drive
2) Backup any files that are different on live (e.g Web.config, Site.csproj, ProjectName.sln)
3) Copy up to live the Web.configs and new .dll files
4) Check the live website is still working




Leave a Comment