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?
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\6.2.267.1\Geolocation\GeoLiteCity.datIf you are testing on your local machine this can often return false as your IP address is local;such as 127.0.0.1 or something in the 192.168.xxx 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 http://stackoverflow.com/questions/1907195/how-to-get-ip-address
C:\Program Files (x86)\EPiServer\Framework\6.2.267.1\Geolocation\GeoLiteCity.dat
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?