我在默认 IIS 站点的 web.config 文件中有以下代码。
<httpModules>
<add type="MDL.BexWebControls.Charts.ChartStreamHandler,Charts" name="ChartStreamHandler"/>
</httpModules>
然后,当我设置并浏览到虚拟目录时,出现此错误
无法加载文件或程序集“图表”或其依赖项之一。该系统找不到指定的文件。
虚拟目录从默认 web.config 继承模块。
你如何阻止这种继承?
最佳答案
我找到了答案。将 HttpModule 部分包装在位置标记中,并将 inheritInChildApplications 属性设置为 false。
<location path="." inheritInChildApplications="false">
<system.web>
<httpModules>
<add type="MDL.BexWebControls.Charts.ChartStreamHandler,Charts" name="ChartStreamHandler"/>
</httpModules>
</system.web>
</location>
现在任何虚拟目录都不会继承此位置部分中的设置。
@GateKiller 这不是另一个网站,它是一个虚拟目录,因此确实会发生继承。
@petrich 我使用
<remove />
获得了成功和失败的结果.我必须记住将它添加到每个虚拟目录中,这很痛苦。
关于.net - 如何防止 IIS 默认站点 web.config 文件被虚拟目录继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37759/