Question

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.

Was it helpful?

Solution

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, e.g:

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

OTHER TIPS

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>

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top