NHibernate exception: Transaction not connected, or was disconnected

后端 未结 3 1970
后悔当初
后悔当初 2021-02-19 12:19

In our develop environment all the ASP.NET application works just fine. However, when I deploy the site on the test machine, on some pages I get this exception:

         


        
3条回答
  •  心在旅途
    2021-02-19 13:02

    There's a problem with your session-per-request pattern implementation. ASP.NET is multi-threaded and the session is being closed when a thread terminates instead of when the request ends. There are many examples of how to manage session-per-request and NHibernate has a built in NHibernate.Context.WebSessionContext but I prefer to use a dependency injection framework such as Ninject.

提交回复
热议问题