EPiServer CMS 6 R2 comes with the great new personalisation feature of Visitor Groups. One of the criterion's available to personalise on is the “geographic location” criteria. Put simply this allows editors to specify a location and/or country to personalise content.
Obviously this functionality utilises a Geo/IP lookup database under the hood. The provider is specified in the EPiServerFramework.config file as follows (in R2 Beta):
I wanted to find a way to use this feature in my own code for use in reporting or possibly in something like a gadget. Allan Thræn had mentioned that it would be available through the EPiServer API so I decided to investigate. It turns out to be remarkably simple:
This code is also available on the EPiServer code section.