How to Prevent MVC 4 Child Application inheriting Parent Application (Umbraco MVC3) web.config

后端 未结 2 963
庸人自扰
庸人自扰 2020-12-19 20:26

I have Umbraco deployed on the server. Currently I am trying to deploy MVC 4 Application as a child application but somehow the child\'s views\\web.config inherits the confi

相关标签:
2条回答
  • 2020-12-19 20:38

    You have a few options. Allow the inheritance and remove the sectionGroup from the child config(s) or something like this in any parent:

    <location path="." inheritInChildApplications="false">
      <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
        <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      </sectionGroup>
    </location>
    

    Intellisense may complain about this however but it should compile and run fine.

    This question might also be of value: Disable web.config inheritance?

    0 讨论(0)
  • 2020-12-19 20:52

    I had the exact same issue. I resolved it by adding an assembly redirect for razor to my child application like this:

    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
       <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31BF3856AD364E35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
     </assemblyBinding>
    </runtime>
    
    0 讨论(0)
提交回复
热议问题