views:

164

answers:

5

I'm deploying a .NET applications to another machine.

in console application, the value of

DateTime.Today.ToLongDateString();

is

10 December 2009

while in web application the value is

23 ذو الحجة 1430 < equivalent in higri calendar

How does the web application get the culture from, and why is it different than the console application?

+2  A: 

It gets it from the machine. See here how you can change it.

klausbyskov
+2  A: 

It's likely to be the culture of the machine itself - you say you're deploying to a different machine.

Which culture do you want it to be in?

EDIT: Your options are:

  • Set the culture for the machine itself, affecting the whole of Windows
  • Possibly set the culture for .NET in general - I'm not sure whether this is available or not in machine.config. It's not something I've ever done.
  • Set the culture for each page
  • Specify the culture explicitly whenever you parse or format strings

The last one is the least invasive, to be honest. Most methods like String.Parse etc have an overload with an IFormatProvider parameter. You can specify this as the relevant CultureInfo.

Jon Skeet
I want the culture to be "en-US" the same as in the console application. From where I can set the culture of the web applications?
ala
A: 
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
DateTime.Today.ToLongDateString();
Paul Creasey
I'm afraid i don't want to change the culture from the code. I'd rather understand where the locale was set on the machine itself. Thanks though
ala
+1  A: 

I got the answer! it was one of the registry records of the users of probably ASPNET or IIS. by using regedit, i found in one of the users international = arabic

Thanks to: http://stackoverflow.com/questions/417497/change-default-locale-in-iis-6-0/1007462#1007462

ala
+1  A: 

In the web.config or machine.config you can specify the default culture for the ASP.Net application through the globalization element.

<configuration>
  <system.web>
    <globalization 
      culture="en-US"/>
  </system.web>
</configuration>
Peter Stuer