Problem with decimals, time, date, culture, conversion etcetera on ASP .Net web page

Does your website look differently depending on which computer or server it is run on, despite the ASP .Net code being exactly the same? This might be fixed programmatically. The problem could be lack of the culture attribute in the web.config file. The problem can occur for instance when the Windows language differs between your development computer and your production server. The computer where you do your web site programming and testing can have Swedish as the Windows language but your server has US English or different regional settings. If this is the case, decimal numbers can be output with a dot (1.23) or a comma (1,23) for instance causing difference in the appearance of two identical web sites or sometimes even runtime errors. Also dates and times can look differently. However, the culture attribute in the ASP .Net web.config file can instruct your web server to interpret your web pages in the same way, despite having different OS languages or settings.

To try this follow this example:

  1. Open your ASP web.config file in a text editor, for example Microsoft Notepad.
  2. Add the culture setting of your choice in the globalization tag (add the globalization tag at the correct place if it doesn’t exists) according to the following example (in this case “Swedish – Sweden”):
<configuration>
<system.web>
  <globalization
    culture="sv-SE"
    uiCulture="sv-SE"
  />
</system.web>
</configuration>

Leave a comment

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