Nested ASP.NET 'application' within IIS inheriting parent config values?

后端 未结 4 1535
借酒劲吻你
借酒劲吻你 2020-11-30 03:22

I currently have 2 x ASP.NET 3.5 web applications in IIS7 (lets call them WebParent and WebChild).

WebChild is nested within the WebParent listing in IIS7 and is set

相关标签:
4条回答
  • 2020-11-30 03:40

    The exact solution to your problem will depend on what configuration exception message you are seeing. However, this is a typical problem that can often be solved through use of the inheritInChildApplications attribute on the location element in the web.config for "WebParent". By wrapping the entire system.web section in a location element as follows, you should be able to eliminate the problem you described:

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

    With IIS 7, you will also want to wrap the system.WebServer section the same way:

    <location path="." inheritInChildApplications="false"> 
      <system.webServer>
        <!-- ... -->
      </system.webServer>
    </location>
    

    This solution is based on an excellent blog article that I found here.

    0 讨论(0)
  • 2020-11-30 03:49

    I think the inheritInChildApplications="false" is good for cases where you still want to inherit some part of the configuration from the parent. In cases where you want to completely stop inheritance (as in this case if I'm correct), I'd suggest to use 2 separate application pools for the 2 apps and then apply a not very well documented setting in the applicationHost.config file as I explained in this question “Entry has already been added” - Two Separate App Pools

    <add name="MyAppPool" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" enableConfigurationOverride="false">
        <processModel identityType="NetworkService" />
    </add>
    
    0 讨论(0)
  • 2020-11-30 03:52

    Follow Scott's advise and also ensure that you have right clicked WebChild in IIS and selected Convert to Application.

    0 讨论(0)
  • 2020-11-30 03:58

    If they are repeated, you'll have to <remove/> then in the child application web.config first, then add back the element you'd like it it's place. This is assuming that you'd like to have a different value. If you don't, then just omit the element. A connection string would be a good example of something that is likely common for all applications - so you only need to specify it in the root.

    Example:

        <siteMap defaultProvider="AdminSiteMapProvider" enabled="true">
          <providers>
            <remove name="AdminSiteMapProvider"/>
            <add name="AdminSiteMapProvider" description="Admin SiteMap provider" type="System.Web.XmlSiteMapProvider" siteMapFile="~/App_Data/admin.sitemap" securityTrimmingEnabled="true" />
          </providers>
        </siteMap>
    
    0 讨论(0)
提交回复
热议问题