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:
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:
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
Copyright © 2022 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, Ipswitch, 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. See Trademarks for appropriate markings.
Powered by Progress Sitefinity