c# - Get And Set Session In Web Service -
i have web service handle login , logout , in web service set session value , session.in log in
[webmethod(enablesession = true)] public object loginbyemail(string email, string password, int regionid) { try { guid? userid = null; int? res = tbll.loginbyemail(ref userid, email, password, regionid); if (res == 1) return new { result = resultenum.notcorrectemailorpassword }; else if (res == 2) { session["user"] = userid; return new { result = resultenum.ok, userid = userid }; } else if (res == 3) return new { result = resultenum.accountnotactive }; else return new { result = resultenum.error }; } catch { return new { result = resultenum.error }; } }
when go definition in session ( session["user"] = userid;) in previous code
[webmethod(enablesession = true)] public object checkifloggedin() { try { return new { result = resultenum.ok, records = getuserid() }; } catch { return new { result = resultenum.error }; } } [webmethod(enablesession = true)] private guid? getuserid() { if (context.session["user"] != null) { string userid = context.session["user"].tostring(); if (userid != "") return new guid(userid); else return null; } else return null; }
in use context.session( string userid = context.session["user"].tostring();) if go definition
my question different between both? , right property using set , session in web service ?
Comments
Post a Comment