Manually Upgrade MVC3 Project to MVC4
To manually upgrade an existing ASP.NET MVC 3 application to version 4, do the
following:
-
In all Web.config files in the project (there is one in the root of the project,
one in the Views folder, and one in the Views folder for each area in your
project), replace every instance of the following text:
System.Web.Mvc, Version=3.0.0.0 System.Web.WebPages, Version=1.0.0.0 System.Web.Helpers, Version=1.0.0.0 System.Web.WebPages.Razor, Version=1.0.0.0
with the following corresponding text:System.Web.Mvc, Version=4.0.0.0 System.Web.WebPages, Version=2.0.0.0 System.Web.Helpers, Version=2.0.0.0, System.Web.WebPages.Razor, Version=2.0.0.0,
-
In the root Web.config file, update the webPages:Version element to "2.0.0.0" and add a newPreserveLoginUrl key that has the value "true":
<appSettings> <add key="webpages:Version" value="2.0.0.0" /> <add key="PreserveLoginUrl" value="true" /> </appSettings>
-
In Solution Explorer, delete the reference to System.Web.Mvc (which points to the version 3 DLL).
Then add a reference to System.Web.Mvc (v4.0.0.0). In particular, make the
following changes to update the assembly references. Here are the details:
-
In Solution Explorer, delete the references to the following assemblies:
- System.Web.Mvc (v3.0.0.0)
- System.Web.WebPages (v1.0.0.0)
- System.Web.Razor (v1.0.0.0)
- System.Web.WebPages.Deployment (v1.0.0.0)
- System.Web.WebPages.Razor (v1.0.0.0)
-
Add a references to the following assemblies:
- System.Web.Mvc (v4.0.0.0)
- System.Web.WebPages (v2.0.0.0)
- System.Web.Razor (v2.0.0.0)
- System.Web.WebPages.Deployment (v2.0.0.0)
- System.Web.WebPages.Razor (v2.0.0.0)
-
In Solution Explorer, delete the references to the following assemblies:
- In Solution Explorer, right-click the project name and then select Unload Project. Then right-click the name again and select Edit ProjectName.csproj.
- Locate the ProjectTypeGuids element and replace {E53F8FEA-EAE0-44A6-8774-FFD645390401} with {E3E379DF-F4C6-4180-9B81-6769533ABE47}.
- Save the changes, close the project (.csproj) file you were editing, right-click the project, and then select Reload Project.
-
If the project references any third-party libraries that are compiled using
previous versions of ASP.NET MVC, open the root Web.config file and add the
following three bindingRedirect elements under the configuration section:
<configuration> <!--... elements deleted for clarity ...--> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.0"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
Comments
Post a Comment