System.Web.HttpContext.Current.Session为NULL值的问题?
2010-09-27 17:12
471 查看
自定义 HTTP 处理程序,从IHttpHandler继承,在写System.Web.HttpContext.Current.Session["Value"]的时候,没有问题,但想将这个Session写到某个变量时或判断是否为空时如:HttpContext.Current.Session["Value"]==null,发现Session的值为NULL,后来查MSDN,看到“在自定义 HTTP 处理程序中实现 IRequiresSessionState 接口,以确定处理程序是否需要对会话状态值具有读写访问权”,在自定义那个类上加上该接口后,果然正常了。
在使用asp.net编写webservice时,默认情况下是不支持session的,但我们可以把WebMethod的EnableSession选项设为true来显式的打开它,如下:
[WebMethod(EnableSession = true)]
public string Login(string name)
{
Context.Session["name"] = name;
return name;
}
在使用asp.net编写webservice时,默认情况下是不支持session的,但我们可以把WebMethod的EnableSession选项设为true来显式的打开它,如下:
[WebMethod(EnableSession = true)]
public string Login(string name)
{
Context.Session["name"] = name;
return name;
}
相关文章推荐
- System.Web.HttpContext.Current.Session为NULL值的问题?
- System.Web.HttpContext.Current.Session为NULL值的问题?
- System.Web.HttpContext.Current.Session为NULL值的问题?
- System.Web.HttpContext.Current.Session为NULL值的问题?
- System.Web.HttpContext.Current.Session获取值出错
- System.Web.HttpContext.Current.Session NullReference错误
- System.Web.HttpContext.Current.Session获取值出错
- .net System.Web.HttpContext.Current.Session 获取值出错(在Page继承类的构造函数中出错)
- .net System.Web.HttpContext.Current.Session 获取值出错(一般处理程序中出错)
- System.Web.HttpContext.Current.Session获取值出错
- System.Web.HttpContext.Current.Session获取值出错
- System.Web.HttpContext.Current.Session为NULL解决方法
- System.Web.HttpContext.Current.Cache与System.Web.HttpRuntime.Cache指向同一个引用
- System.Web.HttpContext.Current.Server.MapPath()
- HttpContext.Current.Session为null的问题
- 异步 HttpContext.Current实现取值的方法(解决异步Application,Session,Cache...等失效的问题)
- System.Web.HttpContext.Current.Cache和System.Web.HttpRuntime.Cache有什么区别?
- 慎用System.Web.HttpContext.Current
- 线程调用方法 System.Web.HttpContext.Current.Server.MapPath()
- 问题:HttpContext.Current.Session;结果:Session与HttpContext.Current.Session到底有什么区别呢?