locked
.Net 2.0: Session not available in HttpModule RRS feed

  • Question

  • User355931397 posted
     Hi,

    I am having a problem whereby Session is always null in a HttpModule I have written.

    I am hooking to the PreRequestHandlerExecute event:

    public void Init(HttpApplication httpApp)
    {     
      httpApp.PreRequestHandlerExecute += new EventHandler(httpApp_PreRequestHandlerExecute);
    }

    void httpApp_PreRequestHandlerExecute(object sender, EventArgs e)
    {
       // ** session always null here:
       ((HttpApplication)sender).Session    
    }

    HOWEVER, if I code this directly into Global.asax, I *can* get session:

    void Application_PreRequestHandlerExecute(object sender, EventArgs e)
    {
       // ** session is OK here:
       ((HttpApplication)sender).Session    
    }

    I have added my HttpModule to web.config, I have also tried explicitly adding the System.Web.SessionState.SessionStateModule to web.config, but to no avail.

    Can anyone see what the problem is??

    Thanks,

    Adam Webber
    Sunday, April 9, 2006 8:52 PM

All replies

  • User933648302 posted
    you have to implement IRequireSessionState
    Sunday, April 9, 2006 9:48 PM