Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a client in the US that wants all time displayed as military time, but everything else is supposed to be US Culture.

In my global.asax I am creating a copy of the US culture and applying the GB time display to create a US culture with Military time.

Reason I am doing this is I could not find a culture capable of it, however if anyone knows, that would be great.

The problem I am running into, is when we deploy the website to IIS (version 6), it all reverts back seemingly to US culture.

Looking up how to change the culture, I found the setting in ASP.NET Tab -> Edit Configuration -> Application Tab

Default value is af-ZA.

There seems to be no option to disable this overriding of culture, and I don't believe af-ZA is right anyways?

Is there a way to prevent IIS from overriding a culture programmatically set in ASP.NET?

Note: Asking here since I'm looking for server side solution, not programming one. Thanks!

share|improve this question

2 Answers 2

up vote 3 down vote accepted

This is at least partially a coding question. Basically, you need to create and register your new culture using the CultureAndRegionInfoBuilder class from System.Globalization.

Once registered, you can then choose your new culture within the ASP.Net application settings. (or within the web.config file for your application.)

Here are some references that should get you started:
http://msdn.microsoft.com/en-us/library/ms172469.aspx
http://msdn.microsoft.com/en-us/library/system.globalization.cultureandregioninfobuilder.aspx

share|improve this answer
    
After finding my own solution, yours looks to be the correct way to do what I was achieving, so marking it as correct. Thanks! –  Brett Allen Feb 23 '10 at 18:29

Found the answer to my question after talking to someone more versed in servers and asp.net

Apparently you can -only- set application wide cultures in the Web.config

I was setting it in the application's main thread in global.asax which did not carry over to child threads processing page requests.

Interesting thing is, when running on local machine through Visual Studio's hosting process, all request must be done through the same thread.

This is what lead me to believe it was an issue with IIS, since not until we put it on IIS did the issue appear.

My solution: (Accepted a more proper solution)

A custom culture must be set on each page request thread. My solution was to put it into the Master page load. IIS does not override your settings.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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