How to check weather the user has performed a login using IServiceClient

I use IServiceClient in the mobile and find once i login in by client.Post(new Autentication(...)), i can reuse the session the next time, that means i needn’t to login when i reopen my App. I want to know if the implement of IServiceClient store session id in the file of mobile.

i use IServiceClient like this,

  1. store a flag in the sqlite of mobile to check if has login before. for example, hasLogin = true.
  2. if hasLogin is true, go to main view to get the data from service.(it’s work perfect.)
  3. if hasLogin is false, go to login view to let customer input it’s username and password. if success, go to 2.
  4. if i get any exception from the service, may be 401 not authentication, i will alert a message to let customer re-login.

I do not know how to use IServiceClient to verify if client has login. is there a standard flow to use Service Stack Client.

Thank you very much.

Are you trying to find out if the client has already logged in or is required to login?

Handling a 401 exception and prompting the user for credentials is a pretty standard way to do it. The ServiceClientBase handles it this way if you are using CredentialsAuthProvider on the server and populating the client with credentials via client.SetCredentials.

If you want to perform some code yourself, you can provide your own callback for the OnAuthenticationRequired action.

Thanks for your help. You answer is wonderful.

I also use exception to check if user has login(I think this method is reasonable because client do not know the session expired in the server or not ). In addition, i want to know how the client store the session in the mobile(because i find i do not need to login every time). Could you tell me where i can find the feature in the source code. I have download the source but i can not build success, do you have a build document. I know it’s better to dig into the code by myself, but it’s a little hard for me because i just use SS two months and i must compete my work very fast these months, may be i will have more time to study after my project have done.

Thank you again.