Search code examples
asp.netglobalization

Do web.config's globalization settings affect non-http requests?


In my ASP.NET application I set

<system.web><globalization culture="pl-PL" uiCulture="pl-PL" />

to have numbers and dates in this culture.

Surprisingly I noticed that methods invoked from job scheduler (Quartz library) use en-US? Why is that?


Solution

  • web.config globalization is relatively simple - it sets thread locale when request is being processed. you seem to be invoking methods from another non-asp.net thread, using Quartz.NET scheduler. The invoker has to set thread locale before calling your methods, so in your job code, set locale manually, then call methods you need, like so:

    Thread.CurrentThread.CurrentCulture = new CultureInfo("pl-PL");
    Thread.CurrentThread.CurrentUICulture = new CultureInfo("pl-PL");