防止在 IIS 7.5 上将父 web.config 继承给子应用程序

Prevent inheriting parent web.config to child Application on IIS 7.5

IIS 7.5 我有父站点使用 parentAppPool 和子应用程序使用 childAppPool.

父站点加载一切正常,但是当我以 http://parentSite.com/SubApplication 访问子应用程序时,它期望来自父站点 bin

的 DLL

为了防止 web.config 继承,我尝试用 <location path="SubApplication" inheritInChildApplications="false"> 包装 <system.web><location path="." inheritInChildApplications="false"> 这会破坏父站点的工作。

然后我尝试将 enableConfigurationOverride="false" 属性添加到 applicationHost.config 中的 SubApplicationPool 也没有用

如有任何帮助,我们将不胜感激。

web.config的高级骨架

当我尝试此操作时,父站点出现 Telerik 错误,但子站点有效!

'~/Telerik.Web.UI.WebResource.axd' is missing in web.config. RadScriptManager requires a HttpHandler registration in web.config. Please, use the control Smart Tag to add the handler automatically, or see the help for more information: Controls > RadScriptManager

如果您希望从继承链中删除特定配置,您可以使用 <clear/> 标签删除父项中任何先前的引用设置,然后您可以重新开始。

以下摘自 here 的示例展示了如何删除以前的会员详细信息并创建新的

 <membership>
   <providers>
      <clear/>
      <add name="AspNetSqlMembershipProvider"
          type="System.Web.Security.SqlMembershipProvider, 
                System.Web, Version=2.0.0.0, 
                Culture=neutral, 
                PublicKeyToken=b03f5f7f11d50a3a"
          connectionStringName="MyDatabase"
          enablePasswordRetrieval="false"
          (additional elements removed for brevity)
       />
   </providers>
 </membership> 

使用 <location> 元素我能够禁用继承。

但这引发了 Telerik 控件的新错误

'~/Telerik.Web.UI.WebResource.axd' is missing in web.config. RadScriptManager requires a HttpHandler registration in web.config. Please, use the control Smart Tag to add the handler automatically, or see the help for more information: Controls > RadScriptManager

为了解决这个问题,我使用了 EnableHandlerDetection 属性,如 Telerik.Web.UI.RadScriptManager Documentation

中所述

EnableHandlerDetection Boolean

Gets or sets a value indicating if RadScriptManager should check the Telerik.Web.UI.WebResource handler existence in the application configuration file.

Remarks

When EnableHandlerDetection set to true, RadScriptManager automatically checks if the HttpHandler it uses is registered to the application configuration file and throws an exception if the HttpHandler registration missing. Set this property to false if your scenario uses a file to output the combined scripts, or when running in Medium trust.

然后又报错了

HTTP Error 500.22 - Internal Server Error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

为了解决这个问题,我对 <system.webserver>

进行了以下更改
 <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>

  <location path="." inheritInChildApplications="false">
  <system.webServer>
    <!--<validation validateIntegratedModeConfiguration="false" />-->
    <modules runAllManagedModulesForAllRequests="true">
    .... other stuff
   </system.webServer>
  </location>