Last active
November 30, 2022 15:06
SF_11.1, SF_11.2, SF_12.0, SF_12.1, SF_12.2, SF_13.0, SF_13.1, SF_13.2, SF_13.3, SF_14.0, SF_14.1, SF_14.2, SF_14.3 - https://docs.sitefinity.com/for-developers-personalization/for-developers-work-with-sitefinity-cms-personalization-geolocation-api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
using Telerik.Sitefinity.Personalization.Impl.GeoData; | |
namespace Sitefinity.Documentation.GeoLocation.Samples | |
{ | |
public class GeoLocationSamples | |
{ | |
public CityLocation FindLocation(string ipAddressString) | |
{ | |
IPAddress ip = null; | |
IPAddress.TryParse(ipAddressString, out ip); | |
var lookupService = new IpCityLocationService(); | |
if (lookupService.IsReady) | |
return lookupService.GetLocation(ip); | |
else return null; | |
} | |
public static void GetCityLocationProperties(CityLocation location) | |
{ | |
var city = location?.City; | |
var country = location?.Country; | |
var region = location?.Region; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment