Skip to content

Get Current User

.NET applications can retrieve an instance of BackendlessUser representing the currently logged in user using the following API call:

BackendlessUser currentUser = Backendless.UserService.CurrentUser;

If a user is not logged in, the method returns null. The method also returns null, if the client application has been restarted since the last  successful login. If the last login used the "persistent login" option (the stayLoggedIn argument set to true), Backendless client saved the objectId value of the logged in user. In this case, the user object can be retrieved with the following API:

Blocking API:

string objectId = Backendless.UserService.LoggedInUserObjectId();
BackendlessUser user = Backendless.Data.Of<BackendlessUser>().FindById( objectId );

Non-Blocking API:

string objectId = Backendless.UserService.LoggedInUserObjectId();

AsyncCallback<BackendlessUser> callback = new AsyncCallback<BackendlessUser>(
  result =>
    // the 'result' argument is the user object

  fault =>
    // server reported an error
  } );

Backendless.Data.Of<BackendlessUser>().FindById( objectId, callback );