Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 26542

IIS8 HttpModule not loading

$
0
0

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.

 


Viewing all articles
Browse latest Browse all 26542

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>