Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I get different date formats when I run my application through IIS and Visual Studio's web server on the same computer?

Tags:

c#

asp.net

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

like image 734
teenup Avatar asked Jun 17 '10 06:06

teenup


People also ask

How do I change the date format in Visual Studio?

In "Control Panel\All Control Panel Items\Region and Language", on the "Formats" tab, click "Additional settings..." button. Visual Studio 2008 debugger formats dates using "Short date:" from the "Date" tab of "Customize Format".

What is the difference between IIS and IIS Express?

An important difference is the way worker processes are managed. In IIS, the Windows Process Activation Service (WAS) silently activates and deactivates Web applications and the user has no direct control. In IIS Express, there is no WAS and the user has full control of application activation and deactivation.


1 Answers

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.

like image 54
Franci Penov Avatar answered Nov 15 '22 06:11

Franci Penov