代码之家  ›  专栏  ›  技术社区  ›  John Owen

如何防止IIS默认站点web.config文件被虚拟目录继承?

  •  17
  • John Owen  · 技术社区  · 18 年前

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

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

    然后,当我设置并浏览到一个虚拟目录时,我得到了这个错误

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

    虚拟目录正在从默认的web.config继承模块。

    你如何阻止这种继承?

    3 回复  |  直到 18 年前
        1
  •  20
  •   John Owen    18 年前

    我找到了答案。将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 />

        2
  •  2
  •   rpetrich    18 年前

    <httpModules>
        <remove name="ChartStreamHandler"/>
    </httpModules>
    
        3
  •  -2
  •   GateKiller    18 年前

    According to Microsoft ,其他网站不会从默认网站继承设置。您是说您正在编辑与machine.config位于同一文件夹中的默认web.config吗?

    推荐文章