9

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.

5 Answers 5

6

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

2
  • 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
    Commented Jan 6, 2009 at 22:14
  • I tried this by putting a web.config in a website for a classic ASP application but it didn't work. I guess it only works for an ASP.NET application and not for changing the locale at the IIS level.
    – John Mills
    Commented Nov 17, 2011 at 23:10
6

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.

4
  • Cheers Nicolas - I'll take a look at that.
    – CJM
    Commented Feb 15, 2009 at 0:34
  • You were right Nicolas, there is actually an option under: Control Panel -> Regional and Language Options -> Advanced -> check the 'Apply all settings to the current user account and to the default user profile'. This worked for me. Thanks.
    – lidermin
    Commented Feb 22, 2011 at 20:59
  • Didn't work for me :( Network Service and Local Service were still set to en-US where I was wanting to change it to en-NZ.
    – John Mills
    Commented Nov 17, 2011 at 23:12
  • Perhaps the version of Windows matters, I was using Win2k3.
    – John Mills
    Commented Nov 17, 2011 at 23:22
4

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.

4
  • Thanks Robert, I'll look into this. Your second option seems favourable - much less invasive.
    – CJM
    Commented Jun 17, 2009 at 15:09
  • Thanks your answer solved my problem :) stackoverflow.com/questions/1879461/…
    – ala
    Commented Dec 10, 2009 at 9:06
  • @robertc - Cheers, modifying the registry is what worked for me. I tried the other solutions provided in the other answers but none of them were effective for the classic ASP/COM+ application I'm having to work on. I used this link to determine the SIDs for the Network Service and Local Service accounts.
    – John Mills
    Commented Nov 17, 2011 at 23:16
  • Better yet, without having to mess with regedit, see windows.microsoft.com/en-ca/windows/…
    – ademar
    Commented Jun 2, 2016 at 14:05
2

Bit of an old thread, but I still look after some legacy Classic ASP sites written by the now defunct Aztec civilisation in praise of their feathered gods.

A server move prevented all the date code from working and sacrificing a chicken was no help, so here is the very easy solution in IIS 7 that has not been mentioned, possibly because no-one else is suffering like me.

  1. Go to IIS Manager.
  2. Select either the root server node to apply to all sites, or select the site node you are having problems with if you want to leave the server default alone.
  3. In IIS section, double click ASP icon.
  4. Set Locale ID to your desired locale (2057 for UK).

This should take effect immediately.

Alternatively you could go buy a DeLorean, go back in time and kill the programmer who decided FormateDateTime(d, vbLongDate) was the best way of generating a date to be used in the database. Or persuade the client to give me a lot of money to replace the whole thing. Either's good.

1

I had a problem, with having the the date formatted mm/dd/yyyy when I wanted it to be dd/mm/yyyy. I am using windows server 2003 and IIS 6

The solution was to add the following to any web config file, then reboot your server and it should work just fine.

<globalization requestEncoding="utf-8" responseEncoding="utf-8"  culture="en-GB" />
1

Not the answer you're looking for? Browse other questions tagged or ask your own question.