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
+3
A:
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.
NerdFury
2009-07-01 19:45:51
Thank you very much! That solved my problem exactly. Thanks for the info. Ha, I just noticed there is a comment in the web.config file about this. I guess I should have looked harder.:P
CalebHC
2009-07-01 20:18:48