Server thread culture

We may create a web application for users in specific region and all the formatting like displaying currency, dates in UI and client side code are done specifically for that culture (say X). These formatting may have different meanings in another culture (say Y).

When a user living in a demographic using culture Y loads the web application, browser sends the request with Accept-Language header in that culture (if the system’s or browser’s default culture is set to culture Y).

If web application is not configured correctly, server will automatically switch the thread culture based on Accept-Language in Request Header, things might go wrong when server side code executes this request with supplied data in a thread with culture set to Y (remember the data is formatted on client side for culture X and sent to server).

Since the web application is targeted for specific demographic, we should explicitly tell the server not to switch the thread culture based on Request Header and configure the application to always use culture X.

For ASP application this configuration can be specified in web.config

Following configuration tells server to automatically switch the thread culture based on Accept-Language in Request Header

Following configuration tells server to always execute the thread culture in en-US culture

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">