Preventing Web.config inheritance on

2019-09-17 18:27发布

问题:

I have been looking for a solution to this for a while but can not find one anywhere...

Background: I have two web applications; one is running Umbraco CMS, this is the root web app. The second is an MVC 4 application and is a Virtual Directory within the root app i.e. /rootapp/quote.

Each app has its own Web.config. Initially I had issues with config inheritance but I resolved this (nearly) by placing using the <location> tag within the parent app config like so:

  <location path="." inheritInChildApplications="false">
    <system.web>
   ....
    </system.web>
  </location>

This fixed the errors but generated a fresh one which I can't fix.. I understand it's because the parent Web.config has already defined Razor.

I have tried <remove name="system.web.webPages.razor"/> within the sub app with no luck, any ideas how to block inheritance..?

Error

Line 3:  <configuration>
Line 4:    <configSections>
Line 5:      <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">
Line 6:        <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" />
Line 7:        <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" />

回答1:

Its the Nature of the beast. My question is whether or not you could modify your deployment so that the quote app was not inside of your root:

Url 1: http://server/root/cms

Url 2: http://server/root/quote

Then configure IIS to redirect any requests to /root to /root/cms