httpModule in Web Application Project not being called when deployed to IIS

448 Views Asked by At

I am in the process of converting out web site project to a web application project. I've got everything to compile and even publish (long process). However, now that I've got the project "loading" in IIS, the httpModule is not called.

The modules section of web.config looks like this:

<modules runAllManagedModulesForAllRequests="true">
        <add name="ContentWebSite" type="ContentWebSite.ContentWebSite"/>
     </modules>

the class of the httpModule starts like this:

namespace ContentWebSite
{
   public class ContentWebSite : IHttpModule
   {
      private HttpApplication _Application;

What am I missing? Setting a breakpoint in the constructor or the init method of the ContentWebSite class is never hit when I'm running in the context of local IIS. When I run in IIS Express, the breakpoint is hit! How do I get IIS to invoke the httpModule?

TIA,

2

There are 2 best solutions below

3
Theobald Du On

You can check if the application pool mode caused your problem.

Application pool mode: classic versus integrated.

enter image description here

<system.webServer><!--for integrated mode-->
    <modules>
      <add name="modulename" type="ContentWebSite.ContentWebSite" />
    </modules>
  </system.webServer>

  <system.web><!--for classic mode-->
     <httpModules>
      <add name="modulename" type="ContentWebSite.ContentWebSite" />
    </httpModules>
  </system.web>
0
Owen On

OK, so I got this working by changing the modules add name line to this:

<add name="modulename" type="ContentWEbSite.ContentWebsite, appName" />

Where appName is the physical name of the DLL generated for the project!