如何防止IIS默认站点的web.config文件被虚拟目录继承?
时间:2020-03-05 18:45:55 来源:igfitidea点击:
我在默认IIS站点的web.config文件中包含以下代码。
<httpModules> <add type="MDL.BexWebControls.Charts.ChartStreamHandler,Charts" name="ChartStreamHandler"/> </httpModules>
然后,当我设置并浏览到虚拟目录时,出现此错误
无法加载文件或者程序集"图表"或者其依赖项之一。该系统找不到指定的文件。
虚拟目录从默认的web.config继承模块。
我们如何停止这种继承?
解决方案
回答
我找到了答案。将HttpModule节包装在位置标记中,并将InheritedInChildApplications属性设置为false。
<location path="." inheritInChildApplications="false"> <system.web> <httpModules> <add type="MDL.BexWebControls.Charts.ChartStreamHandler,Charts" name="ChartStreamHandler"/> </httpModules> </system.web> </location>
现在,任何虚拟目录都不会继承此位置部分中的设置。
@GateKiller这不是另一个网站,它是一个虚拟目录,因此会发生继承。
@petrich我已经使用<remove />
命中和错过了结果。我必须记住将其添加到每个虚拟目录中,这很麻烦。
回答
将以下内容添加到虚拟目录的web.config文件中:
<httpModules> <remove name="ChartStreamHandler"/> </httpModules>
回答
根据Microsoft,其他网站不会从默认网站继承设置。我们是说要编辑默认的web.config,它位于与machine.config相同的文件夹中吗?