How to dispose NHibernate ISession in an ASP.NET MVC App -


In my NHPNET encoding I became a NHibernate.

Everything is fine, if I do not settle ISession. I have read that you should settle, but when I do, I get an exception to the random "session is closed" exception.

I am doing insensitive with Windsor in my other objects.

Here is my current NHModule:

  Public class NHibernateHttpModule: IHttpModule {Public Zero Init (HttpApplication Reference) {context.BeginRequest + = context_BeginRequest; Context.EndRequest + = context_EndRequest; } Fixed Zero Reference_andRquest (Object Sender, EventArgues E) {Current Session Link. UniBind (MVCAction.SessionFactor); } Fixed Zero context_BeginRequest (Object Sender, EventArgs E) {CurrentSessionContext.Bind (MvcApplication.SessionFactory.OpenSession ()); } Public Zero Settlement () {// nothing}}  

Registration of Issition:

  Container & Lt; ISession & gt; () for the Registrar (Component) .UsingFactoryMethod ((=) MvcApplication.SessionFactory.GetCurrentSession ()). LifeStyle.Transient;  

An error occurs when I dispose on unbind in the module. Since I stop stopping the session, I think that is not the right way to do this, so what is the right way?

Thanks, Jo

Robert is correct, Windsor is settling session Instead, when it is releasing components that depend on it, instead of having their own HTML module, I advise to use the ISSATION for Wissner's Pursave Recovery Lifestyle.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -