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 session property

    [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

enter image description here

my question different between both? , right property using set , session in web service ?


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -