简体   繁体   中英

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 ie "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 "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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM