System.Web.HttpContext.Current.Session为NULL值的问题?
2008-05-13 17:19
363 查看
转载 这个问题困扰了我好长时间
“我在类库中调用System.Web.HttpContext.Current.Session, 他是null值,有没有办法取到这个值?
但是我在另一个类库中就可以取到; 两个类都是非page类 , session里面肯定是非空的 ”,网上有人在问这个问题,我后来在编程的时候也碰到了。
我的情况是:自定义 HTTP 处理程序,从IHttpHandler继承,在写System.Web.HttpContext.Current.Session["Value"]的时候,没有问题,但想将这个Session写到某个变量时,发现Session的值为NULL,后来查MSDN,看到“在自定义 HTTP 处理程序中实现 IRequiresSessionState 接口,以确定处理程序是否需要对会话状态值具有读写访问权”,在自定义那个类上加上该接口后,果然正常了。
在这里记一下,以备后查
“我在类库中调用System.Web.HttpContext.Current.Session, 他是null值,有没有办法取到这个值?
但是我在另一个类库中就可以取到; 两个类都是非page类 , session里面肯定是非空的 ”,网上有人在问这个问题,我后来在编程的时候也碰到了。
我的情况是:自定义 HTTP 处理程序,从IHttpHandler继承,在写System.Web.HttpContext.Current.Session["Value"]的时候,没有问题,但想将这个Session写到某个变量时,发现Session的值为NULL,后来查MSDN,看到“在自定义 HTTP 处理程序中实现 IRequiresSessionState 接口,以确定处理程序是否需要对会话状态值具有读写访问权”,在自定义那个类上加上该接口后,果然正常了。
在这里记一下,以备后查
相关文章推荐
- System.Web.HttpContext.Current.Session为NULL值的问题?
- System.Web.HttpContext.Current.Session为NULL值的问题?
- System.Web.HttpContext.Current.Session为NULL值的问题?
- System.Web.HttpContext.Current.Session为NULL值的问题?
- .net System.Web.HttpContext.Current.Session 获取值出错(一般处理程序中出错)
- System.Web.HttpContext.Current.Session获取值出错
- System.Web.HttpContext.Current.Session为NULL解决方法
- System.Web.HttpContext.Current.Session获取值出错
- System.Web.HttpContext.Current.Session获取值出错
- System.Web.HttpContext.Current.Session获取值出错
- .net System.Web.HttpContext.Current.Session 获取值出错(在Page继承类的构造函数中出错)
- System.Web.HttpContext.Current.Session NullReference错误
- System.Web.HttpContext.Current.Cache 与System.Web.HttpRuntime.Cache
- 线程调用方法 System.Web.HttpContext.Current.Server.MapPath()
- abp项目中无法使用HttpContext.Current.Session[""]的问题
- System.Web.HttpContext.Current.Server.MapPath("~/upload/SH") 未将对象引用设置为实例对象
- System.Web.HttpContext.Current vs. ControllerContext.HttpContext (almost the same)
- 慎用System.Web.HttpContext.Current
- System.Web.HttpContext.Current.Cache与System.Web.HttpRuntime.Cache指向同一个引用
- HttpContext为null new HttpContextWrapper(System.Web.HttpContext.Current)