November Happy Hour will be moved to Thursday December 5th.

Current user Id

Vote:
 

Hello guys , 

can someone please tell me how can i get the current user ID , I have managed to get the current user like this : 

var currentUser = EPiServerProfile.Current;

But it doesnt have the id in it 

#193648
Jun 01, 2018 16:35
Vote:
 

Just get the Membership.GetUser.it will contain userid.

why you trying to get the user id.

#193649
Jun 01, 2018 16:58
Vote:
 

You should use PrincipalInfo.CurrentPrincipal instead 

#193652
Jun 01, 2018 17:23
Vote:
 

Quan it doesnt retrieve the current user actually Membership.getUser worked at first but when i used it somewhere else it didn't , long story short Membership.GetUser is not working. 

and what i want is the email and the username and the id of the current User 

EpiserverProfile.Current seem to retrieve the username and the email but not the ID :/ 

#193657
Jun 01, 2018 17:56
Vote:
 

You can get user name from there. Then if you are using Membership provider then Membership.GetUser to find that user. 

HttpContext.Current.User might give you the same information 

#193660
Jun 01, 2018 18:33
Vote:
 

Quan can you please show me how can i Get the user name the user email and the user Id ( as GUID ) using PrincipalInfo.CurrentPrincipal

#193669
Jun 02, 2018 2:02
Vote:
 

Hi Kamal,

For user id:

PrincipalInfo.CurrentPrincipal.GetContactId()

For user name and email:

var customerContact = PrincipalInfo.CurrentPrincipal.GetCustomerContact(); 

Then you get customerContact, that contains name and email.

/Viet Anh

#193771
Jun 05, 2018 8:06
* 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.