SaaS CMS has officially launched! Learn more now.

UserID from User Table


Hello, all I am trying to make a simple request to retrieve the UserID from the Users Table after they have registered the user. 

I have read that there are calls on Commerce Server to get this info:


For user name and email:

var customerContact = PrincipalInfo.CurrentPrincipal.GetCustomerContact(); 

However I cannot find anything on the CMS side that will do the same thing. Any help would be appreciated. 

Mar 27, 2019 20:10
Mar 27, 2019 21:20

Hi Greg

If you are using ASP.Net Identity for authentication, you can get the UserId of a logged-in user like this.

// Inside a controller or view.
string userId = User.Identity.GetUserId();

// Anywhere else.
string userId = PrincipalInfo.CurrentPrincipal.Identity.GetUserId();

Mind you, this method reads the UserId from authentication cookie, not directly from database.

Mar 28, 2019 6:36
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.