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

前端 未结 3 1236
暖寄归人
暖寄归人 2021-02-02 14:24

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


    

        
相关标签:
3条回答
  • 2021-02-02 14:44

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

    <httpModules>
        <remove name="ChartStreamHandler"/>
    </httpModules>
    
    0 讨论(0)
  • 2021-02-02 14:44

    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?

    0 讨论(0)
  • 2021-02-02 15:01

    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.

    0 讨论(0)
提交回复
热议问题