Upgrading the MVC version

Kentico comes with MVC 4 included in the installation.

Note that MVC 5 requires .NET Framework 4.5 / 4.5.1.

The process of upgrading to a newer version of MVC consists of the following steps:

Backup your project before proceeding. This procedure requires you to make changes to the libraries in the project and web.config files.

Removing MVC 4 libraries

  1. Open your Kentico application (WebApp.sln) in Visual Studio.
    1. It is recommended to use Visual Studio 2013 with Update 1 or newer.
  2. In Solution Explorer, remove all the files from the Lib/MVC/ folder.
  3. In the file system, remove all the files from the Lib/MVC/ folder.

Upgrading MVC to a newer version

Now that you removed the libraries of the older MVC version, you need to get the new version of MVC libraries.

You can get the new MVC libraries in one of the two following ways:

Option A - Upgrading MVC to a newer version using the NuGet Package Manager

  1. Right click on the CMSApp_MVC project.
  2. Select the Manage NuGet Packages… option.
  3. Search for MVC’.
  4. Install the Microsoft ASP.NET MVC package.

Once the package installs, continue by Updating the Kentico MVC library.

Option B - Upgrading MVC to a newer version manually

To upgrade MVC to a newer version manually, you need to copy the new version of MVC libraries into the Lib/MVC folder and modify the web.config file to reflect the new version.

To upgrade MVC to a newer version manually

Adding new MVC libraries to your project

  1. Create a new Microsoft ASP.NET MVC Web Application project in Visual Studio.
  2. Select the Web API template and confirm.
  3. Build the project.
  4. In the project’s /bin folder, select the following libraries:
    1. Microsoft.Web.Infrastructure.dll
    2. Newtonsoft.Json.dll
    3. System.Net.Http.Formatting.dll
    4. System.Web.*.dll - that is, all libraries starting with System.Web.
  5. Copy the selected libraries into the Lib/MVC/ folder of your Kentico application.

Updating references to the new MVC libraries

  1. In the CMSApp_MVC project, remove all the references to libraries in the Lib/MVC folder.
  2. Click on Add references.
  3. Switch to Browse… and add the libraries in the Lib/MVC folder that you copied.

Updating the Application web.config file

  1. In the CMS.App project open the web.config file.

  2. Update your web.config file to the new MVC version.

    • You can see the MVC version by right-clicking References-> System.Web.Mvc in the CMSApp_MVC project and selecting Properties.
  3. Locate the <runtime>/<assemblyBinding> section.

  4. In the elements with the name attribute System.Web.Mvc, change the version number from “4.0.0.0” to the new version.

    Updating System.Web.Mvc to version 5.1.0.0
    
    
    
     <dependentAssembly>
         <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
         <bindingRedirect oldVersion="1.0.0.0-5.1.0.0" newVersion="5.1.0.0"/>
     </dependentAssembly>
    
    
     
  5. Save the web.config file.

Continue by Updating the Kentico MVC library.

Updating the Kentico MVC library

  1. Download the Kentico MVC Upgrade from the Marketplace.

  2. Unzip the package and expand the folder for the correct MVC version.

    • See your current MVC version by right-clicking References -> System.Web.Mvc in the CMSApp_MVC project and selecting Properties.
  3. Copy the CMS.MVC<version>.Impl.dll file to the Lib/MVC folder.

Updating the Views web.config file

  1. In the CMSApp_MVC project, open the web.config file located in the Views folder.

  2. Update all elements that contain *S**ystem.Web.WebPages.Razor* from version “2.0.0.0” to version “3.0.0.0”.

    Updating System.Web.WebPages.Razor to version 3.0.0.0
    
    
    
     <configSections>
         <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
             <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
             <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
         </sectionGroup>
     </configSections>
    
    
     
  3. Update the element that contains “System.Web.Mvc.MvcWebRazorHostFactory” from version 4.0.0.0 to the new version of your System.Web.Mvc library.

    Updating System.Web.Mvc.MvcWebRazorHostFactory to version 5.1.0.0
    
    
    
     <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    
    
     
  4. In the <pages> section, update the System.Web.Mvc* elements to the new version of your System.Web.Mvc library. If you don’t plan on using the WebForm view engine, remove the section instead.

    Updating System.Web.Mvc* to version 5.1.0.0
    
    
    
     <pages
         validateRequest="false"
         pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
         pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
         userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
         <controls>
             <add assembly="System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
         </controls>
         ...
     </pages>
    
    
     
  5. Save the web.config file.

  6. Rebuild the solution.