Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

upgrade from mvc 4 (4.5) to mvc 5 (4.5.1)

Tags:

asp.net-mvc

I need to upgrade a MVC 4 project developed in VS 2012 (.NET Framework 4.5) to MVC 5 (.NET Framework 4.5.1).

First Scenario

I've followed the the tutorial on asp.net ( http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2 ).The project builds successfully but when I run it I got an error: 403.14 - The Web server is configured to not list the contents of this directory. The directory browsing is disabled (correct). This should map to /home/index? I have confirmed that the DNS/binding is working by putting a static html file in the site and this works fine.

Second Scenario

I created an empty project in VS2013 and did copy/include all files. It builds successfully and runs on local machine fine but when I publish it to the server I got an error: 403 - Forbidden: Access is denied. I have also confirmed that the DNS/binding is working by putting a static html file in the site.

I have also tried to publish the app’s ‘old version’ (MVC 4) to the server and it works fine.

IDE: VS 2013 .NET Framework: 4.5.1 Local OS: Win 7 SP1 Server: Win Server 2012 Standard

like image 379
user2178726 Avatar asked Dec 04 '22 08:12

user2178726


1 Answers

First of all you need to update all the existing nuget packages.Because some are incompatible with the new one. Before doing it please keep a back up of your existing application

Step 1 : Change the framework to 4.5.1. You need to change the target framework to atleast 4.5 by right clicking the projects.

enter image description hereStep2 : Then you need to update the packages at the solution level.Because it will get the ability to update the packages in all the projects in the solution.For this right click the solution and select 'Manage Nuget Packages for solution' option.

enter image description here

Step3 : From the install packages select the Microsoft.AspNet.Web.Helpers.Mvc packages and Uninstall it.Because it is renamed in the new version ,MVC5.For uninstalling click the Manage button and uncheck the webproject and click ok.

enter image description here

Step4 : Then go to the update packages and update some packages such as Microsoft.ASP.NET MVC,Entity Framework and WebApi version 2. My strategy is to updating to the top level packages.When updating this it will update some ather packages.Now you can see the changes in packages.config file such as MVC4 to MVC5,Razor version change from 2 to 3 and also Webpage version from 2 to 3.

enter image description here

Step5 : Change the version in our config file as well like below.

enter image description here

enter image description here

these are the changes in the top level config file

Step 6 : Then also you need to done some changes in views config file such as updating the razor version to 3 and MVC version to 5 in all the parts of the config file

enter image description here

Step 7 : install one more package. Go to manage nuget manager option >> select online table >> search for Microsoft.Aspnet.Webhelpers and install the package.

enter image description here

**Step 8 : ** Unload the webproject and right click and select edit proj option and the remove the guid starting with E3 because we no need this guid in our new project.

enter image description here

Save and reload the project again and build and run the application Hope this informations helps you

like image 154
Jameel Moideen Avatar answered Dec 26 '22 04:12

Jameel Moideen