Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting a ASP.NET MVC 3 Project to MVC 4

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

like image 743
Petrus Theron Avatar asked Jan 13 '12 15:01

Petrus Theron


People also ask

Is ASP.NET MVC discontinued?

ASP.NET MVC is no longer in active development. The last version update was in November 2018. Despite this, a lot of projects are using ASP.NET MVC for web solution development. As to JetBrains' research, 42% of software developers were using the framework in 2020.

Can we plug an ASP.NET MVC into an existing ASP NET application?

Luckily, the answer is yes. Combining ASP.NET Webforms and ASP.NET MVC in one application is possible—in fact, it is quite easy. The reason for this is that the ASP.NET MVC framework has been built on top of ASP.NET.


2 Answers

The major change is to upgrade the relevant references to the latest version (4.0 /2.0). You need to update your web config files to upgrade 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)

Also you need to update the root level web config 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 referenced in the project. Remove the existing MVC3 dll reference and add MVC4 (use nuget package manager to do this)

This link handles all aspects of the conversion. Refer it as needed.

like image 169
Shyju Avatar answered Oct 16 '22 00:10

Shyju


Follow the official steps posted here:

Upgrading an ASP.NET MVC 3 Project to ASP.NET MVC 4

Note: These steps cover the official release--not the developer preview.

like image 23
Seth Avatar answered Oct 16 '22 01:10

Seth