IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
Sitefinity Personalization module retrieves geolocation data based on the IP of the visitor currently browsing the site. This enables you to specify different personalization criteria based on visitor location, for example, city, country, and so on.
You can leverage the geolocation service functionality in your custom implementation as well. To do this, you first instantiate the Sitefinity IpCityLocationService. To work with the instance of IpCityLocationService you need to check whether it has successfully loaded the GeoLocation database by using its IsReady property. The IsReady property indicates the service is ready for operation. The property may return false in case you are using the IpCityLocationService too early in your code (for example, in the Global.asax). Thus, you make sure Sitefinity has bootstrapped and read its configurations properly. To use the service in Global.asax, make sure to implement the call to IpCityLocationService in the Bootstrapper_Bootstrapped event handler as demonstrated in the following example:
IpCityLocationService
IsReady
Global.asax
Bootstrapper_Bootstrapped
Once you verify the service is ready, you call its GetLocation method by passing an IPAddress parameter. If a match is found for the specified IP address, IpCityLocationService returns a CityLocation object that contains the City, Country, ISO Code, Region, PostalCode, geographic coordinates of the matched location. Refer to the sample below on how to use IpCityLocationService in your code:
GetLocation
IPAddress
CityLocation
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important