web.config 的全球化设置会影响非 http 请求吗?

发布于 2024-10-02 22:52:44 字数 209 浏览 5 评论 0原文

在我的 ASP.NET 应用程序中,我设置

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

了这种文化中的数字和日期。

令人惊讶的是,我注意到从作业调度程序(Quartz 库)调用的方法使用 en-US?这是为什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我乃一代侩神 2024-10-09 22:52:44

web.config 全球化相对简单 - 它在处理请求时设置线程区域设置。
您似乎正在使用 Quartz.NET 调度程序从另一个非 asp.net 线程调用方法。调用者必须在调用您的方法之前设置线程区域设置,因此在您的作业代码中,手动设置区域设置,然后调用您需要的方法,如下所示:

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

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");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文