Location Personalization with IP addressCancel

I have problem using location personalization. I understand that location personalization is based on IP address of the incoming request and sitefinity tries to match the IP address against a location+ IP database.

Is the ip address sitefinity uses for location personalzation the same as the ip address in the following function? based on servervariables ["HTTP_X_FORWARDED_FOR"] or ["REMOTE_ADDR"]? I appreciate if someone can answer because it helps to debug the issue.

We get the IP address from the current request context (UserHostAddress property), see below:

protected virtual IPAddress VisitorIP

{

get

{

if (string.IsNullOrEmpty(this.Context.Request.UserHostAddress))

return IPAddress.None;

IPAddress ip = IPAddress.None;

if (IPAddress.TryParse(this.Context.Request.UserHostAddress, out ip))

{

return ip;

}

return IPAddress.None;

}

}

Regards,
Radoslav Georgiev
Telerik

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Thanks Rado. so according to your answer, if a load balancer proxy server is used, for location personalization purpose, sitefinity will use "this.Context.Request.UserHostAddress", which is the IP address of the proxy server?
If it is the case, from what I have read, the originating IP address is in the HTTP_X_FORWARDED_FOR variable. Is there a way to override the way sitefinity works get the ip address(VisitorIP method) so we can use the HTTP_X_FORWARDED_FOR instead for location personalziation purpose?

You can substitute the built in evaluators for IP and Location in order to get the user IP in the way you suggest. This can be used as a solution while I get to the development team and make changes in the built in code. So for example create 2 classes which will override the built in evaluators:
Location:

using Telerik.Sitefinity.Personalization.Impl.Evaluators;

namespace SitefinityWebApp

{

public class CustomLocationEvaluator : LocationEvaluator

{

protected override System.Net.IPAddress VisitorIP

{

get

{

//replace default implementation with yours

return base.VisitorIP;

}

}

}

}

IP:

using Telerik.Sitefinity.Personalization.Impl.Evaluators;

namespace SitefinityWebApp

{

public class CustomIPAddressEvaluator : IPAddressEvaluator

{

protected override System.Net.IPAddress VisitorIP

{

get

{

//replace default implementation with yours

return base.VisitorIP;

}

}

}

}

Then what you will need to do is to register the custom classes with the Unity container and replace the default implementation. This can be done in Global.asax:

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Webinars

Tools

Progress, Telerik, Sitefinity and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries.