Erroneous Character displayed instead of $ sign or currency symbol
Hi all,
This time I want to discuss how globalization features affect the behavior of an ASP.NET application. I recently worked with a customer who had an ASP.NET application which outputs a $ sign in front of the currency. Instead of the "$" sign, it would display a different symbol. This issue was sporadic. If you refresh the page, it would go away.
Most of these settings are controlled by the culture of the executing thread. This property is obtained from the Request.Headers(0) parameter. When you request a webpage, the browser sends the currently used language to the web application on the server. The web application can then use this information to present a localized web page for that user. This property also sets the Thread.CurrentThread.CurrentCulture property. ASP.NET 2.0 has the ability to automatically detect the requesting browsers language and use it for localization.
We checked the property of Thread.CurrentThread.CurrentCulture and found that when the erroneous character was displayed, this property was null. However it was set to en-US when the page worked properly or was refreshed.
RESOLUTION
We set the culture explicitly in the @Page attribute and that resolved the issue here. Here are a couple of knowledge base articles from the Microsoft website that explain how to set the culture attribute in page as well as in code;
HOW TO: Set Culture Information in an ASP.NET Application Without Code
https://support.microsoft.com/?id=326943
HOW TO: Set Current Culture Programmatically in an ASP.NET Application
https://support.microsoft.com/?id=306162
CAUSES
There are many reasons why the culture setting may be lost.
1. You are using a control or any third party controls that explicitly sets the culture.
2. You are programmatically changing the culture in code
Hope this post helped with any such issue.
Thank you!
3. Your application is configured to use the language sent by the browser.