Why I get different date formats when I run my application through IIS and Visual Studio's web server on the same computer?
I get the same culture i.e. "en-US" while running the website from both IIS and Visual Studio's web server.
But I get a different date format as follows, when I run the following code:
HttpContext.Current.Response.Write(System.Threading.Thread.CurrentThread.CurrentCulture.ToString());
HttpContext.Current.Response.Write(System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern);
On Visual Studio's web server: dd/MM/yyyy en-US
On IIS: M/d/yyyy en-US
Does "Regional and Language Options" in "开发者_JAVA百科Control Panel" play any role in this ? If I change the date format there in "Regional and Language Options", I see no effect in my application.
The IIS server (or rather the ASP.NET worker process) is running under a different account, while the VS web server is running under your user account. Thread.CurrentCulture
gets the current culture for the user account the thread is executing as.
精彩评论