trying to implement session per web request, No current session context configure

送分小仙女□ 提交于 2019-12-05 20:01:10
Cole W

1st Question

You need to configure it in your nhibernate configuration section:

<property name="current_session_context_class">web</property>

Also I currently do something like this:

if (!CurrentSessionContext.HasBind(SessionFactory))
{
    CurrentSessionContext.Bind(SessionFactory.OpenSession());
}

2nd Question

Please look at the following article to modify configuration fluently: currentsessioncontext fluent nhibernate how to do it?

3rd Question

You are closing your session twice.

using (ISession session = SessionProvider.Instance.GetCurrentSession()) 

closes your session. Then you did it again in Application_EndRequest. If you have another question please post a new question.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!