Upgrading a web app from ASP.NET MVC 3 to ASP.NET MVC 4
I recently had to update a web application from ASP.NET MVC 3 to ASP.NET MVC 4. Here are the the steps I had to go through to do that:
1) Update your project references. The easiest way to do that is to install ASP.NET MVC 4.0 from Package Manager Console:
That will download and install all necessary components and will update your project references.
2) In your root Web.config, in <system.web> / <assemblies>
section, update the assembly versions for System.Web.Helpers
, System.Web.Mvc
and System.Web.WebPages
, i.e. replace this:
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
with this:
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
3) In Views\\Web.config
, replace all instances of System.Web.Mvc, Version=3.0.0.0
and System.Web.WebPages.Razor, Version=1.0.0.0
with System.Web.Mvc, Version=4.0.0.0
and System.Web.WebPages.Razor, Version=2.0.0.0
.
Those three basic changes were enough to get my web application running. Depending on your application you may have to do more changes. For a complete list of all changes that might be required, check out the upgrade section in the ASP.NET MVC 4 release notes.