How do you prevent the IIS default site web.config file being inherited by virtual directories?

旧巷老猫 提交于 2019-12-02 21:49:38

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 This isn't another website, its a virtual directory so inheritance does occur.

@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.

Add the following to the virtual directory's web.config file:

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

According to Microsoft, other websites do not inherit settings from the Default Website. Do you mean you are editing the default web.config which is located in the same folder as the machine.config?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!