Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate Session with IIS 7

I have a ASP.NET MVC application using NHibernate and the application runs fine when running it through VS2008 virtual web server, but when I tried running the site through my local IIS server I keep getting this NHibernate error: No session bound to the current context. I don't know what happened. Am I missing something? I just have my IIS Default Website pointing to the application's web directory where it runs the Default.aspx page. Any ideas? Thanks

like image 249
CalebHC Avatar asked Jul 01 '09 17:07

CalebHC


1 Answers

Are you managing your context with an HttpHandler or HttpModule? IIS7 requires a different configuration group in the web.config for these.

<system.webServer>
 <modules></modules>
 <handlers></handlers>
</system.webServer>

This should go outside the <system.web /> node.

You probably have an <httpHandlers /> and <httpModules /> section already, these work with IIS6, but not IIS7 unless you are running in the legacy mode.

It is also possible that if you are ending your session when the EndRequest event is fired, that it is being fired by a request for an image or other static resource which will have its request end before the call to your action method.

like image 72
NerdFury Avatar answered Oct 19 '22 22:10

NerdFury