Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

View as a Visitor Group in CMS preview mode not working


I have some pages set to be visible for specific user group in the CMS. When I try to preview it using the View as Visitor group in toggle section I still see the pages that the selected role should not be seeing.

In the application UI, the content is filtered and is displayed correctly. Its only when using preview option in CMS.

Am I missing something ?

Feb 24, 2020 21:42

How does you configure them? I hope you are not using the visitor group criteria. You must be using access rights to set access.

Visitor group criteria is for website visitors (frontend website, not CMS), to control who should see what content

Access rights should be used to set Read, write, create etc permissions

Feb 25, 2020 1:43


If I understand the situation correctly, the reason you'll always be seeing the pages regardless of the visitor group selected is that you will already have permission to see that page by virtue of being a CMS admin (or editor). Impersonating a visitor group adds to the permissions you already have rather than replacing them.

If you want to use the visitor group impersonation to replace existing permissions, you'd need to write a custom filter which checks the ACLs of each content item in your list and removes any items which don't have "everyone" access and don't have access to the impersonated visitor group (as I recall, you can get the impersonated visitor group from the HttpContext.Items collection).

Feb 25, 2020 12:14

So to update here. I have the visitor group created and also have set the access rights. Now in the preview when I select a visitor group that should not be seeing certain content. I find that the visitor group selection doesn't do anything. I can still see the content that shouldnt be visible to the group.


Could you please give me some more information on what custom filter we are talking about?

Feb 25, 2020 14:52

Hi Dileep,

I think the first paragraph in your update above reinforces what I'd said above. Permissions in Episerver are additive so previewing as a visitor group wouldn't remove any permissions and wouldn't result in the removal of access to any content. You'll still be previewing with your own permissions plus those of the visitor group you're impersonating.

Presumably you're getting a list of content (e.g. pages) then filtering using something like EPiServer.Filters.FilterContentForVisitor() to remove the content items which the user shouldn't have access to? What I was suggesting was that, in addition to that first filter call, you could create your own filter method which, if you're impersonating a visitor group, will strip out any of the content which is not available anonymously unless it's visible to the visitor group you're impersonating. Something like this:

public static IEnumerable<T> FilterForVisitorGroupImpersinationPreview<T>(this IEnumerable<T> contents) where T : IContent
    var impersonatedVG = (System.Web.HttpContext.Current.Items["ImpersonatedVisitorGroupsById"] as string[])?.FirstOrDefault() ?? string.Empty;
    if (string.IsNullOrEmpty(impersonatedVG))
        return contents; // Don't filter if you're not impersonating a group

    //impersonatedVG contains the GUID of the visitor group, ACL entries contain the name so get the name from the GUID
    var vgRepo = ServiceLocator.Current.GetInstance<IVisitorGroupRepository>();
    var vgName = vgRepo.Load(Guid.Parse(impersonatedVG)).Name;

    var rtn = new List<T>();
    foreach (var item in contents)
        var securable = item as IContentSecurable;
        var securityDescriptor = securable.GetContentSecurityDescriptor();

        var everyoneHasAccess = securityDescriptor.Entries.Any(x => x.Name.Equals("Everyone") && x.Access.Equals(AccessLevel.Read) && x.EntityType.Equals(SecurityEntityType.Role));
        var impersonatedVGHasAccess = securityDescriptor.Entries.Any(x => x.Name.Equals(vgName) && x.Access.Equals(AccessLevel.Read) && x.EntityType.Equals(SecurityEntityType.VisitorGroup));

        if (everyoneHasAccess || impersonatedVGHasAccess)
    return rtn;
Feb 25, 2020 17:54
Dileep D - Apr 16, 2020 17:51
Thanks for this. I will give it a try.


I'm new to episerver. I'm currently working on visitor groups. So I've tried the builit in criteria and set it as  security role and it is not working. 

So right now I'm trying to integrate my visitor group using personalized content, When I tried to select a visitor group there is none on the list.

I'm thinking that I miss something in configuration. I'm trying to find documentation related to this but no luck.



Edited, Apr 15, 2020 21:27
* 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.