Umbraco Error: Section or group name ‘system.web.webPages.razor’ is already defined. This can not be defined multiple times.
If you are getting this error most likely you installed Umbraco via Nuget using Visual Studio 2015. If that’s the case, then your solution is really simple.
VS 2015 doesn’t support MVC 4 which is the default with the Umbraco 7.2 Nuget installation at present, so
you gotta upgrade it to MVC 5.
Alternatively, there is one more thing it could be, and this is one is quite annoying and I hope they fix this very soon.
This will also happen if you don’t pick the “Empty Project” template when creating your project in Visual Studio and pick MVC instead. Essentially, as the error message suggests you end up with multiple section declarations in your web.config, but not even the main one, the one on the Views folder.
So to fix it, go to your Views folder, open Web.config and right at the top you’ll see that the sectiongroup for system.web.webPages.razor is declared twice. Delete the one referring to the oldest version of Razor. At present the declaration targets 188.8.131.52; it’s the bottom one and looks like this:
<sectionGroup name=”system.web.webPages.razor” type=”System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=184.108.40.206, Culture=neutral, PublicKeyToken=31BF3856AD364E35″>
<section name=”host” type=”System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ requirePermission=”false” />
<section name=”pages” type=”System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=18.104.22.168, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ requirePermission=”false” />
You’re not done yet! If you try to run now you’ll still get another error. This is the same thing and for the same reason but this time for the MvcWebRazorHostFactory.
So on that same Views/Web.config search for System.Web.Mvc.MvcWebRazorHostFactory and remove the following line :
<host factoryType=”System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ />
You will find there are two of those, so the one you want to delete is the MVC 4 one if you are going to be using MVC 5.