Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Hi,
this is what I've done in a project:
public IPAddress GetIPAddress()
{
var request = System.Web.HttpContext.Current.Request;
string ipString;
if (String.IsNullOrEmpty(request.ServerVariables["HTTP_X_FORWARDED_FOR"]))
{
ipString = request.ServerVariables["REMOTE_ADDR"];
}
else
{
ipString = request.ServerVariables["HTTP_X_FORWARDED_FOR"].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
.FirstOrDefault();
}
IPAddress result;
if (!IPAddress.TryParse(ipString, out result))
{
result = IPAddress.None;
}
return result;
}
Then, later by using episervers geolocation (maxmind) api,
var prov = Geolocation.Provider;
var result = prov.Lookup(ipAddress);
Hope it works.
I got a point in the right direction and the solution was pretty simple
public static List<VisitorGroup> GetUserVisitorGroups()
{
var visitorGroupHelper = new VisitorGroupHelper();
var visitorGroups = new VisitorGroupStore();
IEnumerable<VisitorGroup> groups = visitorGroups.List();
var userVisitorGroups = new List<VisitorGroup>();
foreach (var group in groups)
{
if (visitorGroupHelper.IsPrincipalInGroup(Thread.CurrentPrincipal, group.Name, new HttpContextWrapper(HttpContext.Current)))
{
userVisitorGroups.Add(group);
}
}
return userVisitorGroups;
}
I then compared the groups with the ACL key on the page(i set the visitor group as authorized to view the page)
Hi
Im trying to filter pages from code behind.
I have visitor groups created on different areas of sweden.
When a user arrives to the page I collect a list of pages, customer service.
I want to do a check from code which page to present data data from but also be able to override the visitor group.
If i am in Stockholm i should get the customer service from stockholm but also be able to change and view Gothenburg.
I cant seem to find any examples of how to do this from code behind.
/Pär