EPiServer 7.5, EPiServer Add-On

EPiServer Languages Add-On requires replacePrincipal=”true”

Just a short reminder to me and maybe to you that EPiServer Languages Add-On (1.1.1.7514) requires currently replacePrincipal=”true” in virtualRoles configuration.

Longer story: Needed to test some multi-language related idea. So I dediced to create a POC about it and fastest way is to create a new MVC Alloy site using the Visual Studio template. Happily updated NuGets and the database. Then I added the EPiServer Language Add-On. Added some languages in the admin configuration and enabled the languages on the Alloy site.

Navigated to the start page and added the Languages gadget to the side panel. The gadget title appeared but there was no options so I just reloaded the page but still nothing. Hmmm. Clicking the blocks showed sometimes the option to create content in other language but nothing happened when clicking the command. Opened Firebug console and reloaded the UI which immediately revealed that something is wrong:

NetworkError: 500 Internal Server Error
http://www.demositeaddresshere.com/EPiServer/EPiServer.Labs.LanguageManager/Stores/language/null

Looking at the error log of the site shows an entry:

ERROR EPiServer.Global: 1.2.5 Unhandled exception in ASP.NET
System.InvalidCastException: Unable to cast object of type 'System.Web.Security.RolePrincipal' to type 'EPiServer.Security.VirtualRolePrincipal'.
   at EPiServer.Labs.LanguageManager.Controllers.LanguageStore.IsCurrentUserInAdminRole()

So something to do with the virtual roles and looking at web.config (episerver.framework section):

<!-- this is the default virtual roles config by the VS template -->
<virtualRoles addClaims="true">
  <providers>
	<add name="Administrators" type="EPiServer.Security.WindowsAdministratorsRole, EPiServer.Framework" />
	<add name="Everyone" type="EPiServer.Security.EveryoneRole, EPiServer.Framework" />
	<add name="Authenticated" type="EPiServer.Security.AuthenticatedRole, EPiServer.Framework" />
	<add name="Anonymous" type="EPiServer.Security.AnonymousRole, EPiServer.Framework" />
	<add name="CmsAdmins" type="EPiServer.Security.MappedRole, EPiServer.Framework" roles="WebAdmins, Administrators" mode="Any" />
	<add name="CmsEditors" type="EPiServer.Security.MappedRole, EPiServer.Framework" roles="WebEditors" mode="Any" />
	<add name="Creator" type="EPiServer.Security.CreatorRole, EPiServer" />
	<add name="PackagingAdmins" type="EPiServer.Security.MappedRole, EPiServer.Framework" roles="WebAdmins, Administrators" mode="Any" />
  </providers>
</virtualRoles>

Then I remembered that I’ve had this issue already earlier and it was about replacing the principal. So looking at the virtual roles documentation and changing the configuration to:

<virtualRoles addClaims="false" replacePrincipal="true">
...
</virtualRoles>

fixes the issue and the Languages Add-On works as it should 😉

Footer note: Yes I used ILSpy first to have a look at the EPiServer.Labs.LanguageManager.Controllers.LanguageStore.IsCurrentUserInAdminRole() method ;D

One thought on “EPiServer Languages Add-On requires replacePrincipal=”true”

Leave a comment