Try our conversational search powered by Generative AI!

Current user Id


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 

Jun 01, 2018 16:35

Just get the will contain userid.

why you trying to get the user id.

Jun 01, 2018 16:58

You should use PrincipalInfo.CurrentPrincipal instead 

Jun 01, 2018 17:23

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 :/ 

Jun 01, 2018 17:56

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 

Jun 01, 2018 18:33

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

Jun 02, 2018 2:02

Hi Kamal,

For user id:


For user name and email:

var customerContact = PrincipalInfo.CurrentPrincipal.GetCustomerContact(); 

Then you get customerContact, that contains name and email.

/Viet Anh

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.