views:

2294

answers:

3

I've got a hosted VPS hosted by a UK hosting company that for some reason is set to US settings. In fact, until recently, the regional settings were 'English - United States'. I've corrected the regional settings, but my application is still working with the wrong date format. See:

http://www.albaassoc.com/events/listevents.aspx

The default dates are supposed to be the current date to the date + 3 months, but as you can see, the dd and MM fields are swapped. Note: the AJAX calendar extender is manually set to dd/MM/yyyy so that is why the calendar pop thinks we are interested in June/July rather than January!

I know there are various ways to set a page or an application to use a particular locale, but I'd rather go for a global approach.

Is it possible to re-configure IIS to work in a different locale, or if not, can I tweak machine.config so that it is a once-only change?

I've got a ticket open with the host but I'm not going to hold my breath - they aren't going to want to reinstall IIS...

Thanks in advance.

+2  A: 

Via the globalization element, you can set the culture and uiculture for a site (via web.config) or the entire machine (via machine.config).

Robert C. Barth
hmmm... tried that. Intellisense didn't like the culture attribute, and it didn't seem to work anyway. I'll post the code I tried when I'm back at my desk.
CJM
+1  A: 

I just got a similar issue (Windows Server 2008, IIS 7). I was able to fix it by editing the web config file, but like you I wanted a global fix.

The solution is in the config panel, regional settings. I don't know for you (what's your OS), but under WS2008, there is an administrative tab under regional settings. It allows you to copy the settings of your logged in user (you) to the administrative accounts (network services in this case). Rebooted and got it right.

Nicolas Cadilhac
Cheers Nicolas - I'll take a look at that.
CJM
+2  A: 

The problem is often that the user running either IIS or the application pool your app belongs to is a system account which was created when the server was installed. They therefore inherited whatever the default locale was at the time.

If you can't fix it in regional and language options you can always try editing in the registry directly (with the usual proviso that messing around with the registry can seriously muck up Windows). The regional settings are all under HKEY_USERS\{userid}\Control Panel\International - if you compare what's there for each user with what you have under HKEY_CURRENT_USER\Control Panel\International it should be fairly obvious what to change. I've done this a few times on Windows 2000 servers and it's worked OK.

The other option is just to create a new user on the machine with the correct locale and then set both IIS and the application pool to run with that identity.

robertc
Thanks Robert, I'll look into this. Your second option seems favourable - much less invasive.
CJM
Thanks your answer solved my problem :) http://stackoverflow.com/questions/1879461/date-format-in-asp-net-versus-in-console-application
ala