Try our conversational search powered by Generative AI!

Checking if current user is in visitor group



I'm trying to determine if a visitor belongs to a visitor group from code. It returns false everytime when I use geolocation, but works when I tested a span of time. I've checked so virtualroles replaceprincipal is set to true.

This is my code:

var visitorGroups = new VisitorGroupStore(DynamicDataStoreFactory.Instance).List().OrderBy(v => v.Name);

foreach (var group in visitorGroups)


bool isInRole = newVisitorGroupHelper().IsPrincipalInGroup(PrincipalInfo.CurrentPrincipal, group.Name);


Any ideas about what I'm doing wrong?


May 24, 2013 17:38

Isn't this just a problem with geolocation?

Gelocation uses your IP address against a known database, by default stored at C:\Program Files (x86)\EPiServer\Framework\\Geolocation\GeoLiteCity.dat

If you are testing on your local machine this can often return false as your IP address is local;such as or something in the range, also sometimes production environment setups behind load balancers don't correctly pass through the originating client IP address meaning geolookup doesn't work correctly.

Why don't you try logging out the incoming IP address to check its value - see



May 24, 2013 19:57

Thanks, I'll try that! As soon as we get the production servers I can test this more thoroughly.

Btw. Do you know how to mark a post as answered in the new forum?

Edited, May 27, 2013 11:41
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.