首页 > 代码库 > WebSessionStore: Could not obtain reference to HttpContext
WebSessionStore: Could not obtain reference to HttpContext
IBatis.net在多线程中报错“WebSessionStore: Could not obtain reference to HttpContext”
分析:
因为ibatis的ISqlMapSession是存储在Http.Request.Items上的,在你新开的线程里是不能操作IIS的上的线程的,根据ibatis的文档上说的,可以用:HybridWebThreadSessionStore
The DatatMapper component store his working ISqlMapSession on different session store.
On Web environnement, the session is stored Http.Request.Items.
On windows environnement on the current thread.
You can configure the session storage by specifing the property ISessionStore on ISqlMapper.
This will allow to set a custom session store like the HybridWebThreadSessionStore This is used for scenarios where most of the you need per request session, but you also does some work outside a request (in a thread pool thread, for instance).
Set it after the configuration and before use of the ISqlMapper.
On Web environnement, the session is stored Http.Request.Items.
On windows environnement on the current thread.
You can configure the session storage by specifing the property ISessionStore on ISqlMapper.
This will allow to set a custom session store like the HybridWebThreadSessionStore This is used for scenarios where most of the you need per request session, but you also does some work outside a request (in a thread pool thread, for instance).
Set it after the configuration and before use of the ISqlMapper.
解决:
重新指定SessionStore
_SqlMapper.SessionStore = new HybridWebThreadSessionStore(_SqlMapper.Id);
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。