码迷,mamicode.com
首页 > Web开发 > 详细

WebSessionStore: Could not obtain reference to HttpContext

时间:2014-07-11 22:52:37      阅读:331      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   art   

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.

解决:

重新指定SessionStore

_SqlMapper.SessionStore = new HybridWebThreadSessionStore(_SqlMapper.Id);

 

bubuko.com,布布扣

WebSessionStore: Could not obtain reference to HttpContext,布布扣,bubuko.com

WebSessionStore: Could not obtain reference to HttpContext

标签:style   blog   http   color   os   art   

原文地址:http://www.cnblogs.com/sword88/p/3833078.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!