U4-3469 - Umbraco 7 + MVC 4 + nuget, web.config error

Created by Pintér Ákos 10 Nov 2013, 16:42:56 Updated by Mikael Syska 21 Nov 2013, 22:26:49

Is duplicated by: U4-3461

*I created an MVC 4 Empty web project *I deleted: App_Data contents, web.config of Views folder and global.asax *I get the Umbraco Belle RC via nuget (Install-Package UmbracoCms -Pre) and I chose replacing my original web config (Y) *At the Database setup step I chose a local SQL Server Database *I installed Text starter kit *I successfully logged in to the backend *The error is that I can't load the main page of the site, because the web.config file of the Views folder is invalid

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Unrecognized configuration section system.web.webPages.razor.

Source Error:

Line 1: Line 2: Line 3: <system.web.webPages.razor> Line 4: Line 5: }

Comments

Søren Reinke 11 Nov 2013, 12:50:53

I have tested the Nuget installing without doing the deliting of 'App_Data contents, web.config of Views folder and global.asax'.

Had no problems.


Pintér Ákos 11 Nov 2013, 22:21:32

OK, I see.

I followed the instructions of this video [http://umbraco.tv/videos/developer/fundamentals/surface-controllers/setting-up-the-vs-solution/] , but in this case is the video or the nuget package the wrong?

In the nuget package the Views/web.config doesn't declare system.web.webPages.razor .


Søren Reinke 12 Nov 2013, 07:17:53

Hi Pintér

Not sure where the error is.

The web.config in my view folder starts like this:

<system.web.webPages.razor> </system.web.webPages.razor>


Shannon Deminick 12 Nov 2013, 09:34:06

Hi,

Can you please attach 3 files to this issue: ~/web.config ~/views/web.config and ~/macroscripts/web.config so we can have a look?


Joost van den Berg 14 Nov 2013, 09:31:48

The ~/views/web.config from Nuget differs from the nightly build .zip file. If i use that file the error is away.


Shannon Deminick 14 Nov 2013, 10:09:02

Hi, so you are saying the one in the nightly build is correct yeah ?


Joost van den Berg 14 Nov 2013, 10:22:33

Hi Shannon; yes the one from the nightly is correct


Mikael Syska 14 Nov 2013, 20:46:24

The web.config in the views folder looks like this when installing from NuGet. Umbraco 7.0-RC

<!--
    Enabling request validation in view pages would cause validation to occur
    after the input has already been processed by the controller. By default
    MVC performs request validation before a controller processes the input.
    To change this behavior apply the ValidateInputAttribute to a
    controller or action.
-->
<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <controls>
    <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
  </controls>
</pages>

</system.web> <system.webServer>

<handlers>
  <remove name="BlockViewHandler" />
  <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>

</system.webServer>

This is the missing part for some reason:


Søren Reinke 14 Nov 2013, 21:23:55

This is the file from my Nuget install 2 days ago, the section is not missing.

I install from nuget with:

Install-Package UmbracoCms -pre

<system.web.webPages.razor> </system.web.webPages.razor>

<system.web>

<!--
    Enabling request validation in view pages would cause validation to occur
    after the input has already been processed by the controller. By default
    MVC performs request validation before a controller processes the input.
    To change this behavior apply the ValidateInputAttribute to a
    controller or action.
-->
<!--
    Enabling request validation in view pages would cause validation to occur
    after the input has already been processed by the controller. By default
    MVC performs request validation before a controller processes the input.
    To change this behavior apply the ValidateInputAttribute to a
    controller or action.
--><pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <controls>
    <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
  </controls>
</pages>

</system.web>

<system.webServer>

<handlers>
  <remove name="BlockViewHandler" />
  <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>

</system.webServer>


Mikael Syska 14 Nov 2013, 21:26:37

I'm using Visual Studio 2013 and newest NuGet ... maybe that is why mine is failing.


Søren Reinke 14 Nov 2013, 21:33:31

My test was in Visual Studie 2012 Pofessional with i think the newest nuget plugin.

Very strange.


Mikael Syska 14 Nov 2013, 22:02:30

Just tested in VS 2012 ... same problem.

It's like it for some reason is being deleted cause there is some empty space where it should be.

If I look in the downloaded content for the package. This file "Web.config.transform" in the "\packages\UmbracoCms.7.0.0-RC\Content\Views" folder is there containing this:

<system.web>

<!--
    Enabling request validation in view pages would cause validation to occur
    after the input has already been processed by the controller. By default
    MVC performs request validation before a controller processes the input.
    To change this behavior apply the ValidateInputAttribute to a
    controller or action.
-->
<pages
    validateRequest="false"
    pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <controls>
    <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
  </controls>
</pages>

</system.web>

<system.webServer>

<handlers>
  <remove name="BlockViewHandler"/>
  <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>

</system.webServer>

So i'm actually wondering where that other part comes from.

What does your NuGet package "\packages\UmbracoCms.7.0.0-RC\Content\Views\Web.config.transform" file contain?


Søren Reinke 15 Nov 2013, 07:55:30

This i getting strange now.

My file contains the same as yours, it looks like, i'll do a bit more testing now to see if i can figure out what is happening.

<system.web>

<!--
    Enabling request validation in view pages would cause validation to occur
    after the input has already been processed by the controller. By default
    MVC performs request validation before a controller processes the input.
    To change this behavior apply the ValidateInputAttribute to a
    controller or action.
-->
<pages
    validateRequest="false"
    pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <controls>
    <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
  </controls>
</pages>

</system.web>

<system.webServer>

<handlers>
  <remove name="BlockViewHandler"/>
  <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>

</system.webServer>


Mikael Syska 15 Nov 2013, 08:10:02

Do note, that it only fails when accessing the site ... the Umbraco backend is working.


Søren Reinke 15 Nov 2013, 08:58:27

I have tested again, this time in Visual Studio 2013 Professional, and checked that the Nuget plugin is the newest version.

In Visual Studio 2013 i get the same error as you have.

So i tested again in Visual Studio 2012, and it did work. The problem is that in the empty MVC4 template in VS2013, there is no View's folder and no default web.config in that folder. But there is in VS2012, and the nuget install only changes a few things in the existing web.config in the views folder. Thats why it is working. (i think)

So the section you are mentioning is missing in the nuget's web.config file for the views folder.


Mikael Syska 15 Nov 2013, 09:04:01

Makes sense ... I used Empty WebProject i both cases.


Shannon Deminick 15 Nov 2013, 09:14:43

I'm not sure if it helps but if no config file exists there we generate one with our view engines when they render


Mikael Syska 15 Nov 2013, 09:24:38

I will try that.

But the problem now is that for some reason NuGet genetates an invalid web.config in the Views folder when installing. Missing the configSections part of the web.config.

So ... I would guess that NuGet should not create or transform any files in the Views folder if the file does not exist. This would solve the problem I guess.


Sebastiaan Janssen 19 Nov 2013, 14:13:57

Fixed in rev 313b831559ec21aa7bb66479eb1621f93e2fa40a


Mikael Syska 21 Nov 2013, 22:26:49

Not sure if this is the right commit: https://github.com/umbraco/Umbraco-CMS/commit/313b831559ec21aa7bb66479eb1621f93e2fa40a

I'm no GitHub guru, just copied the guid and replaced it with another.

I have created a new issue that it generates an invalid web.config.


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category: Installation

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.0.0

Due in version: 7.0.0

Sprint:

Story Points:

Cycle: