我在默认 IIS 站点的 web.config 文件中有以下代码。

<httpModules>
    <add type="MDL.BexWebControls.Charts.ChartStreamHandler,Charts" name="ChartStreamHandler"/>
</httpModules>

然后,当我设置并浏览到虚拟目录时,出现此错误

无法加载文件或程序集“图表”或其依赖项之一。该系统找不到指定的文件。

虚拟目录继承默认 web.config 中的模块。

怎样才能阻止这种继承呢?

有帮助吗?

解决方案

我已经找到答案了。将 HttpModule 部分包装在位置标记中,并将继承InChildApplications 属性设置为 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>

据微软称, ,其他网站不会继承默认网站的设置。您的意思是您正在编辑与 machine.config 位于同一文件夹中的默认 web.config 吗?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top