Try our conversational search powered by Generative AI!

Getting enduser current location using Cloudflare


We want to gend user current user location details like country and region based on IP, by using Cloudflare. And for that we have added below keys in our solution as below:

<add key="episerver:ClientIPAddressHeader" value="True-Client-IP" />

<add key="episerver:ClientLocationHeader" value="CF-IPCountry" />

 But, still are not getting any key in header as  “CF-IPCountry” in browser website. Please help on this

Jan 21, 2022 11:57

Hi Rajveer,

Do you have a geolocation provider configured?

Header-based geolocation is only used when no geolocation provider has been configured and that it is limited to Country and Continent locations.


Jan 24, 2022 9:39
- Jan 25, 2022 11:02
As per my understanding, with DXP it will come automatically.. and i am using an DXP instance.
And i am not aware about, how geolocation provider is configured.

Hi Rajveer

I think there is a bit misunderstanding. how do you retrieve the CF-IPCountry? In you controller, do you get any value from this code Request.Headers["CF-IPCountry"]?

Edited, Feb 12, 2022 0:21

Hi Rajveer

The configuration entries you mention are only used for location-based Visitor Groups. If you need the country code in custom code, you can use the same implementation as Visitor Groups, by calling:


An alternative would be:


Be aware that Cloudflare will only detect the country, not continent, region or city. However, the first method will also give you continent (by internal mapping). Detection needs to be enabled in Cloudflare, so check with Episerver Support whether it is enabled by default.

Edited, Feb 12, 2022 15:17
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.