Will ASP.NET cache culture setting?

  • Thread starter Thread starter Hardy Wang
  • Start date Start date
H

Hardy Wang

Hi,
We migrated some of web applications to a new server. When the server
was installed, the regional setting was EN-CA, later on we found culture
display was not same as from original server (which was EN-US), we reset
server's culture to EN-US.
Now we have 2 web applications still behaviouring as EN-CA setting. It
recoginizes string "03/01/2003" as Januray 3rd 2003, not March 1st 2003.
I checked code, nothing is wrong. I check regional setting of server
(Windows 2000 Advanced Server), it is "English United States", short format
is "M/d?yyyy". I created a small piece of windows application program to
test on this server, it works fine. Only two web applications do not look
good.

So I am wandering when ASP.NET is installed on machine, will it remember
culture selection at that time? I really think not possible, but the factor
makes to suspect.
 
Hi,

My advice is to set the culture explicitly and to stop worrying about what
Windows and .NET Framework believe it should be. In the
Application_BeginRequest handler set the following:

System.Threading.Thread.CurrentThread.CurrentCulture =
new System.Globalization.CultureInfo("en-US");

(with or without the semi-colon at the end depending on the language you are
using)

Hope this helps
Martin Dechev
ASP.NET MVP
 
Yes, I would agree with you.

I think set culture and uiCulture of globalization section in web.config
should also work.
 
Back
Top