简体   繁体   中英

Disabling HttpModule on certain location

I know that this has already been asked here but the answer (using a handler instead) doesn't solve the issue, as I'm using a third party component that doesn't implement IHttpHandler.

So, again, is there any way to load/unload a HttpModule on a certain request?

EDIT: I forgot to mention that we're working with .NET 2.0. I'm sorry about forgeting it.

I haven't tested this, but a comment in this article seems to suggest that it is possible to register modules only for certain locations by using a <location > element in web.config, eg:

  <location path="some/path">
    <system.web>
      <httpModules>
        <remove name="name"/>
        <add name="name" type="type"/>
      </httpModules>
    </system.web>
  </location>

One way you could do this is with a wrapper module. Register one httpModule with your application then create rules in this module which correspond to running other modules. You have access to the request object so you should be able to detect what kind of request you're getting and route the logic off to the relevant (custom) module.

I assume that the problem is with the inheritance of the HttpModule, do you need the inheritance of your web.config with the third party control?

Try adding this attribute where the path will be where you component is stored;

<location path="/ThirdPartyComponents" inheritInChildApplications="false">
    ...
</location>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM