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 dep开发者_JS百科loying my app to IIS 7: ActiveRecord's SessionScope.Current seems to be not available for some reason.
Any ideas?
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.
If you're using IIS 7 Integrated Mode you need to register the ActiveRecord HttpModule in the system.webServer/modules section instead of system.web/httpModules
See
- http://www.west-wind.com/weblog/posts/168221.aspx
- http://msdn.microsoft.com/en-us/library/ms227673.aspx
精彩评论