- I’m having a problem with an application on a specific server.
On every environment except the problem environment
The server correctly recognizes that all clients are in the UK and parses UK formatted dates:
DD/MM/YYYY
On the problem server
The problem only appears to happen on one server. This server seems to incorrectly require american dates:
MM/DD/YYYY
What I’ve tried already
- Adding a “globalization” section to web.config file to attempt to force en-GB culture
- Checking the “machine.config’s” globalization section (it says en-GB as well).
- I’ve checked that the clients are requesting en-GB as the prefered culture for the respnse.
- At Eoin’s suggestion I’ve also checked the regional settings for the server (they have the date set to dd/MM/yyyy which is correct).
What I cannot try
I’m using MS ASP.NET MVC which is automatically de-serializing the HTML form data into an object, so I can’t manually specify the date format — e.g. using DateTime.Parse(myDateStr, "dd/MM/yyyy") as the parsing is done by Microsoft MVC.
Is there anything else I can do. This is an intranet app, and all clients are in the UK.
You needs to do following two things.
Set Culture in web.config as given below
uiCulture=”en-GB” culture=”en-GB” .
Set your form method to POST as I have mentioned below
DailyReport is your controller action method, Reports is controller and most important thing is FormMethod.Post by setting form method to POST will solve your Date format problem.
Enjoy!