Umbraco Error: Section or group name ‘system.web.webPages.razor’ is already defined. This can not be defined multiple times.

Posted by matheus@guimak.com |07 Sep 15 | 0 comments

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 2.0.0.0; 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=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″>
<section name=”host” type=”System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ requirePermission=”false” />
<section name=”pages” type=”System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ requirePermission=”false” />
</sectionGroup>

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=4.0.0.0, 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.

 

 

 


Leave a Reply

Your email address will not be published. Required fields are marked *