你怎么prevent被继承的虚拟目录的IIS默认网站的web.config文件?你怎么、虚拟目录、文件、网站

2023-09-03 09:14:19 作者:回忆最折磨人

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

I have the following code in a web.config file of the default IIS site.

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

后来,当我设置和浏览到我得到这个错误虚拟目录

Then when I setup and browse to a virtual directory I get this error

无法加载文件或程序集图表或它的某一个依赖。该系统找不到指定的文件。

Could not load file or assembly 'Charts' or one of its dependencies. The system cannot find the file specified.

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

The virtual directory is inheriting the modules from the default web.config.

你怎么阻止此继承?

推荐答案

我已经找到了答案。裹在位置标签的HTTP模块部分,将inheritInChildApplications属性设置为false。

I've found the answer. Wrap the HttpModule section in location tags and set the inheritInChildApplications attribute to false.

<location path="." inheritInChildApplications="false">
  <system.web>
    <httpModules>
      <add type="MDL.BexWebControls.Charts.ChartStreamHandler,Charts" name="ChartStreamHandler"/>
    </httpModules>
  </system.web>
</location>

现在任何虚拟目录不会继承此位置部分中的设置。

Now any virtual directories will not inherit the settings in this location section.

@GateKiller这不是另一个网站,它是一个虚拟目录,以便继承确实发生了。

@GateKiller This isn't another website, its a virtual directory so inheritance does occur.

@petrich我已经打了使用&LT小姐的结果;删除/&GT; 。我一定要记住将其添加到这是一种痛苦的虚拟目录中。

@petrich I've had hit and miss results using <remove />. I have to remember to add it to every virtual directory which is a pain.