Search code examples
iis-7castle-activerecordlinq-to-nhibernate

Castle ActiveRecord: SessionScope.Current is null under IIS 7


I'm using ASP.Net MVC (still 1.0 for now) with Castle ActiveRecord and NHibernate.Linq. All is fine under IIS 6.

However, I'm faced with a problem deploying my app to IIS 7: ActiveRecord's SessionScope.Current seems to be not available for some reason.

Any ideas?


Solution

  • In order to use the same web.config file on IIS7 and older versions, put the SessionScopeWebModule in the section like this:

    <configuration>
        <system.webServer>
          <validation validateIntegratedModeConfiguration="false"/>
          <modules>
             <add name="ar.sessionscope" type="Castle.ActiveRecord.Framework.SessionScopeWebModule, Castle.ActiveRecord" />
    

    in addition to the original <system.web> section settings:

    <configuration>
       <system.web>
          <httpModules>
                  <add name="ar.sessionscope" type="Castle.ActiveRecord.Framework.SessionScopeWebModule, Castle.ActiveRecord" />
    

    Make sure you set the <validation validateIntegratedModeConfiguration="false"/> in the <system.webServer> section as well.