2011年4月1日

Webservice Session使用方法 又一篇

摘要: 在webService 有两个方法1. [WebMethod(Description = "登录",EnableSession=true)]public bool ClientLogin(string uNmae, string pwd){//连接数据库验证用户登录//创建一个sessionSystem.Web.HttpContext.Current.Session["UserName"] = username;return true;}2.[WebMethod(Description = "获取登录用户名称",EnableSessi 阅读全文

posted @ 2011-04-01 10:56 Jan.David 阅读(4335) 评论(2) 推荐(2)

在webservice中使用session和cookie

摘要: 要在webservice中使用session,1.需要在服务端的方法中加入[WebMethod(EnableSession=true)]修饰方法,2.在客户端,要在实例化了webservice代理类之后,要为它的CookieContainer 实例化一个 new CookieContainer();这样才能使用session存储状态。3.另外在多个webservice代理中,只要含有相同的cookie,就能共用相同的session,其中的cookie通过代理类的CookieContainer.GetCookies(new Uri(s.Url))["ASP.NET_SessionId& 阅读全文

posted @ 2011-04-01 08:56 Jan.David 阅读(20229) 评论(6) 推荐(2)

导航