HttpModule with ASP.NET MVC not being called

Posted by mgroves on Stack Overflow See other posts from Stack Overflow or by mgroves
Published on 2009-09-07T21:45:29Z Indexed on 2010/03/30 7:33 UTC
Read the original article Hit count: 519

I am trying to implement a session-per-request pattern in an ASP.NET MVC 2 Preview 1 application, and I've implemented an IHttpModule to help me do this:

public class SessionModule : IHttpModule
{
    public void Init(HttpApplication context)
    {
        context.Response.Write("Init!");
        context.EndRequest += context_EndRequest;
    }
    // ... etc...
}

And I've put this into the web.config:

  <system.web>
    <httpModules>
      <add name="SessionModule" type="MyNamespace.SessionModule" />
    </httpModules>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="SessionModule" />
      <add name="SessionModule" type="MyNamespace.SessionModule" />
    </modules>

However, "Init!" never gets written to the page (I'm using the built-in VS web server, Cassini). Additionally, I've tried putting breakpoints in the SessionModule but they never break. What am I missing?

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2

Related posts about asp.net-mvc