How to Upgrade an ASP.NET MVC 4 and Web API Project to ASP.NET MVC 5 and Web API 2
====================
by [Rick Anderson](https://github.com/Rick-Anderson)
> ASP.NET MVC 5 and Web API 2 bring a host of new features, including attribute routing, authentication filters, and much more. See [https://www.asp.net/vnext](https://www.asp.net/core) for more details.
>
> This walkthrough will guide you with the steps required to upgrade your application to the latest version.
>
> > [!NOTE]
> > Please see [ASP.NET and Web Tools for Visual Studio 2013 Release Notes](../../../visual-studio/overview/2013/release-notes.md) for information on breaking changes from MVC 4 and Web API to the next version.
>
>
>
> This article was written by Youngjune Hong and Rick Anderson ( [@RickAndMSFT](https://twitter.com/#!/RickAndMSFT) )
## Upgrade Steps
1. Backup your project. This walkthrough will require you to make changes to your project file, package configuration, and web.config files.
2. For upgrading from Web API to Web API 2, in global.asax, change:
3. Make sure all the packages that your projects use are compatible with MVC 5 and Web API 2. The following table shows the MVC 4 and Web API related packages than need to be changed. If you have a package that is dependent on one of the packages listed below, please contact the publishers to get the newer versions that are compatible with MVC 5 and Web API 2. If you have the source code for those packages, you should recompile them with the new assemblies of MVC 5 and Web API 2.
> Microsoft-Web-Helpers has been replaced with Microsoft.AspNet.WebHelpers. You should remove the old package first, and then install the newer package.
>
> There is no cross version compatibility among major ASP.NET packages. For example, MVC 5 is compatible with only Razor 3, and not Razor 2.
4. Open your project in Visual Studio 2013.
5. Remove any of the following ASP.NET NuGet packages that are installed. You will remove these using the Package Manager Console (PMC). To open the PMC, select the **Tools** menu and then select **Library Package Manager,** then select **Package Manager Console**. Your project might not include all of these.
1.`Microsoft.AspNet.WebPages.Administration`
This package is typically added when upgrading from MVC 3 to MVC 4. To remove it, run the following command in the PMC:
6. Upgrade all the ASP.NET NuGet packages using the PMC. In the PMC, run the following command:
`Update-Package`
The `Update-Package` command without any parameters will update every package. You can update packages individually by using the ID argument. For more information about the update command, run `get-help update-package` .
## Update the Application *web.config* File
Be sure to make these changes in the app *web.config* file, not the *web.config* file in the *Views* folder.
Locate the `<runtime>/<assemblyBinding>` section, and make the following changes:
1. In the elements with the name attribute "System.Web.Mvc", change the version number from "4.0.0.0" to "5.0.0.0". (Two changes in that element.)
2. In elements with the name attribute "System.Web.Helpers" and "System.Web.WebPages" change the version number from "2.0.0.0" to "3.0.0.0". Four changes will occur, two in each of the elements.
2. Update all elements that contain "System.Web.WebPages.Razor" from version "2.0.0.0" to version"3.0.0.0". If this section contains "System.Web.WebPages", update those elements from version "2.0.0.0" to version"3.0.0.0"
3. If you removed the `Microsoft-Web-Helpers` NuGet package in a previous step, install `Microsoft.AspNet.WebHelpers` with the following command in the PMC:
`Install-Package -Id Microsoft.AspNet.WebHelpers`
4. If your app uses the [User.IsInRole()](https://msdn.microsoft.com/en-us/library/system.web.security.roleprincipal.isinrole(v=vs.110).aspx) method, add the following to the *Web.config* file.