Get current users language settings in CMS 12?



In CMS 11 I could get the logged in persons languagesettings usign this:

var profileLanguage = EPiServerProfile.Current.Language;

How is this done in CMS 12? I cannot find anything in the documentation?



Dec 06, 2021 10:43

I still have not figuerd this on out, anyone?


Dec 15, 2021 21:48

Hi Kristoffer,

This is how it's done in CMS 12:

// constructor injection...
private readonly IPrincipalAccessor _principalAccessor;
private readonly IUserMembershipService _userMembershipService;


var userMembershipInfo = await _userMembershipService.GetUser(_principalAccessor.CurrentName());
var language = userMembershipInfo.Language;

Hope this helps!

Dec 16, 2021 20:06

Thanks Dejan!

I guess this should be ok to:

var userMembershipInfo =  _userMembershipService.GetUser(User.Identity.Name);


Edited, Dec 16, 2021 21:09

Nope, that did not work but yours did. Thanks again!

Dec 17, 2021 10:06
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.