Jack Mills
Jack Mills

Reputation: 6132

RegionInfo seems to be incorrect

I have a function that's designed to tell me which country my websites being run in (The website is run on a UK and Irish server). Basically I use:

RegionInfo.CurrentRegion.EnglishName;

To get this information. However when I run this function on the Irish server I still get "United Kingdom" returned. The web servers regioning in the control panel is set up as being Irish so I don't know where it's going wrong.

Any ideas? Thanks

Upvotes: 0

Views: 2209

Answers (1)

adrianbanks
adrianbanks

Reputation: 83014

RegionInfo.CurrentRegion uses CultureInfo.CurrentCulture as the basis for the region it returns. This in turn uses the CurrentCulture of the current thread. If a culture has not been set on the thread, it defaults to the "user default culture" - which it gets from the underlying OS.

As Henk says, this is determined by the Formats section in the regional control panel applet, not the location. If the formats section is set to Ireland, RegionInfo.CurrentRegion.EnglishName does output Ireland.

Upvotes: 3

Related Questions