locked
IIS8 HttpModule not loading RRS feed

  • Question

  • User-642472087 posted

    I am trying to test a module on IIS8 (Windows 8) and as far as I can tell it is not being loaded. In order to understand the problem I have broken it down to about the most basic example can find.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Web;
    
    namespace HttpModuleTest
    {
        public class TheModule : IHttpModule
        {
            // In the Init function, register for HttpApplication 
            // events by adding your handlers.
            public void Init(HttpApplication application)
            {
                application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
                application.EndRequest += (new EventHandler(this.Application_EndRequest));
            }
    
            // Your BeginRequest event handler.
            private void Application_BeginRequest(Object source, EventArgs e)
            {
                HttpApplication application = (HttpApplication)source;
                HttpContext context = application.Context;
                context.Response.Write("<h1><font color=red>HelloWorldModule: Beginning of Request</font></h1><hr>");
            }
    
            // Your EndRequest event handler.
            private void Application_EndRequest(Object source, EventArgs e)
            {
                HttpApplication application = (HttpApplication)source;
                HttpContext context = application.Context;
                context.Response.Write("<hr><h1><font color=red>HelloWorldModule: End of Request</font></h1>");
            }
    
            public void Dispose()
            {
            }
        }
    }

    The module has been registered using the IIS user interface which generates the following in web.config:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.web>
            <identity impersonate="false" />
        </system.web>
        <system.webServer>
            <modules>
                <add name="HttpModuleTest" type="HttpModuleTest.TheModule" />
            </modules>
        </system.webServer>
    </configuration>

    I have tried running an app pool in clasic mode (module registered in system.web) and Integrated mode (module registered in system.webServer).

    The IIS application has a simple static default.htm page.

    The module dll is deployed in the applications bin folder (and was happily found by the registration UI).

    I am probably missing something very simple/obvious but I cannot understand why the module is not loaded. Any suggestion would be appreciated.

     

    Friday, August 23, 2013 11:39 AM

All replies

  • User212506688 posted

    Hi,

    Did this work when you ran it from within Visual Studio?

    Maybe try a differetn event like PageLoad...

    Also, did you set the Build Action of the module to Compile?

    HTH, Benjamin

    Friday, October 4, 2013 10:37 AM