Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Geta Episerver geolocation tools


For ASP.NET 5+ and Episerver/Optimizely 12+ see:

This library can be used to retrieve the languagebranch which matches the given request best. It provides methods to retrieve a preferred languagebranch by a users' geolocation, browser language preference or both. The commerce library can be used to find the right market and corresponding language based on the same parameters. Useful to prompt the user that a different language might suit him/her better. Useful for setting the right market for a user or for suggesting a specific market and language. Builds on top of Episervers' built in support for geolocation


  • Get languagebranch by geolocation, preferred browser languages or both
  • [Commerce] Get market by geolocation and preferred browser languages
  • Override ip address for local development testing (by setting a cookie)

How to get started?

  • install-package Geta.EPi.GeolocationTools
  • install-package Geta.EPi.GeolocationTools.Commerce


Local development

For local development add a cookie to override the ip adress to an ip you want to test. Either in code:

// This will be gone next request
Request.Cookies.Add(new HttpCookie(Geta.EPi.GeolocationTools.Constants.IPAddressOverride)
	Value = "", // Chinese ip address
	Expires = DateTime.Now.AddYears(1)
var result = _commerceGeolocationService.GetMarket(Request);

// This will be there upon the next request
HttpContext.Response.SetCookie(new HttpCookie(Geta.EPi.GeolocationTools.Constants.IPAddressOverride)
    Value = "",
    Expires = DateTime.Now.AddYears(1)
// Chinese market (if available)
var result = _commerceGeolocationService.GetMarket(Request);

Or add a cookie "geolocation_ip_override" in your browser dev tools. Dev tools cookie

Test IPs

Country code IP

Code example for Geta.EPi.GeolocationTools

public class LanguageBranchExample : Controller
    private readonly IGeolocationService _geolocationService;

    public LanguageBranchExample(
        IGeolocationService geolocationService)
        _geolocationService = geolocationService;

    public void Index()
        // Gets the language based on the users' location and their browser preferences, depending on what is available.
        // 1. Language branch for both the users' country and their browser preferences
        // 2. Language branch for users' browser preferences
        // 3. Fallback language
        var languageBranch = _geolocationService.GetLanguage(Request);

Code example for Geta.EPi.GeolocationTools.Commerce

Register ICurrentMarket implementation

 public class StructureMapRegistry : Registry
    public StructureMapRegistry()

Get market based on geolocation and browser preferences

public class MarketExample : Controller
    private readonly ICurrentMarket _currentMarket;
    private readonly ICommerceGeolocationService _commerceGeolocationService;

    public MarketExample(
        ICurrentMarket currentMarket, 
        ICommerceGeolocationService commerceGeolocationService)
        _currentMarket = currentMarket;
        _commerceGeolocationService = commerceGeolocationService;

    public void Index()
        // Get current market based on geolocation and browser preferences, market, language, location can be null
        var result = _commerceGeolocationService.GetMarket(Request);
        // This one will be cached by storing the result in a cookie
        // Will fall back to first enabled market or the default market
        var sameMarket = _currentMarket.GetCurrentMarket();

Package maintainer