Rolosoft.comRolosoft Geo IP.NET Documentation
Compatibility with ASP.NET Caching

There are some special considerations when using Geo IP.Net with ASP.net caching. The considerations are identical to those when using the ASP.net framework Culture=Auto option.

Rolosoft Geo IP.NET automatically sets the culture very early on in a page lifecycle. If the page is then cached in ASP.NET (e.g. by using the @OUTPUTCACHE directive), the culture is cached too. This means that if, for example, the first visit from a page is from The Republic of China, subsequent calls to the page will be set to Chinese even if the calls are from elsewhere in the world.

There are two solutions to this issue:-

  1. Disable Output caching.
  2. Keep output caching enabled but define a consistent culture for the page (see below for further details).
Defining a Consistent Culture for a Specific Webpage.

Sometimes, you will not want to "Localize" a webpage. For example, if your website lists and sells products in dollars($) to a worldwide market, you would probably NOT want to automatically change the culture of a page based on a users IP/Country.

Defining a consistent culture for for cached or commerce pages can be achieved by overriding the page InitializeCulture event as follows:-

CopyExample of How to Set a Consistent Culture for ASP.NET Webpage
protected override void InitializeCulture()
{
    Thread.CurrentThread.CurrentCulture=new CultureInfo("en-US");
    Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
    base.InitializeCulture();
}

The page level InitializeCulture() event is fired after Geo IP.Net automatically sets the culture. It therefore allows you to define a consistent culture / user experience where needed.