2008-09-01 146 views
17

我在默认的IIS站点的web.config文件中有以下代码。如何防止IIS默认站点web.config文件被虚拟目录继承?

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

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

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

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

你如何阻止这种继承?

回答

20

我找到了答案。将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 />命中并错过了结果。我必须记住将其添加到每个虚拟目录中,这是一个痛苦。

+0

是的,我发现它也是一种痛苦。感谢关于inheritInChildApplications的提示。 – rpetrich 2008-09-11 20:14:11

2

以下添加到虚拟目录的web.config文件:

<httpModules> 
    <remove name="ChartStreamHandler"/> 
</httpModules> 
-2

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

+0

我认为提问者正在讨论从它继承的站点的虚拟目录。 – Sam 2013-08-19 23:41:19