1. January 2012 12:14
I messed with this issue for about a month. I recently migrated an old ASP.NET 2.0 application on a private server with Windows 2008 Server R2 Enterprise OS installed. The application consists of few entry forms where date is to be entered in dd/mm/yyyy format. This application has a TextBox to enter the date and not a DateTime picker. Sometimes DateTime picker is not easy to work with when you need to enter old dates often and if you want to keep it null sometimes.
ASP.NET shows error: “Input String was not in a correct format” when date is entered in dd/mm/yyyy format. I re-checked SQL Server documentation, changed SQL Server’s default language for default login (though not recommended), but nothing seemed to solve the problem.
My last workaround with IIS Settings solved the issue.
I am using Windows Server 2008 R2 which comes with IIS 7. Open IIS and right-click the virtual directory of your application.
Now select Properties and in the right pane you could see an option: .NET Globalization.
In my case, the default Culture was set to Invariant Culture even though default language was set to English (US).
Change the Culture and UI Culture to English (United Kingdom), as show below:
This small change solved the issue. Here I also recommend that you keep your SQL Server’s default settings intact. The standard and globally accepted date format is: yyyy/mm/dd which is acceptable by all database applications without any problem. You should first try out the tips given above before tampering your default database format.