ASP.NET – How to set culture in web.config to change regional settings

In ASP.NET, if you get messages similar to the following:

* String was not recognized as a valid DateTime
* The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

It is feasible that the webserver and/or Db is running on different regional culture sets.

To fix this,add a globalization section to the Web.config file, and then set the uiculture and culture attributes, as shown in the following example:

 <globalization uiCulture="en" culture="en-NZ" />

The full list of cultures can be found here:
https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo(v=vs.110).aspx

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.