.net webservices 处理Session

来源:互联网 发布:如何申请为淘宝达人 编辑:程序博客网 时间:2024/05/29 14:14

至于Session的问题:
1、服务的Method要用EnableSession=true
2、客户要能处理Cookie,在.net中很Easy的

//  [ WebMethod(Description="Per session Hit Counter",EnableSession=true)]
//  public int SessionHitCounter()
//  {
//  
//   if (Session["HitCounter"] == null)
//   {
//    Session["HitCounter"] = 1;
//   }
//   else
//   {
//    Session["HitCounter"] = ((int) Session["HitCounter"]) + 1;
//   }
//   return ((int) Session["HitCounter"]);
//  }

要加上EnableSession=true才可以访问Session。

 

原创粉丝点击