我的父 Web 应用程序配置文件中有以下内容
<configuration>
<configSections>
<sectionGroup name="testmodule">
<section name="testmodule" type="RewriteModule.RewriteModuleSectionHandler, RewriteModule"/>
</sectionGroup>
</configSections>
</configuration>
我想防止子文件夹继承这个配置部分我应该放在哪里
<location path="." inheritInChildApplications="false">
, 因为配置部分应该是配置文件的第一个子元素
最佳答案
这已经在 SO 上回答了几次,但我认为是错误的。
文档非常清楚 (1)(2):
The following example shows how to use this attribute in a configuration file to specify that the settings defined in the location element for the root of a Web site should not be inherited by child applications:
The InheritInChildApplications property applies only to location-specific configuration settings.
要回答您的问题,这应该足够了:
<configuration>
...
<sectionGroup name="testmodule">
<section name="testmodule" type="RewriteModule.RewriteModuleSectionHandler, RewriteModule"/>
</sectionGroup>
...
<location path="." inheritInChildApplications="false">
<testModule>
....
</testModule>
</location>
关于c# - 如何防止 "configSections"的 web.config 文件继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4030891/