在 VS 开发服务器和 IIS 上为 ASP.NET MVC 应用程序设置文化 [英] Setting Culture for ASP.NET MVC application on VS dev server and IIS
问题描述
这是这个问题的更具体和更清晰的版本 - 开发和测试环境的不同 DateTimeFormat
在我的 ASP.NET MVC 项目中 global.asax.cs 的 Application_BeginRequest() 方法中有代码:
In the Application_BeginRequest() method of global.asax.cs in my ASP.NET MVC project there is code:
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");
当我在 Controller Action 上设置断点时,我看到 Thread.CurrentThread.CurrentCulture 的以下值:
When I set a breakpoint on Controller Action I see the following value of Thread.CurrentThread.CurrentCulture:
- 在 VS 开发服务器中 - en-GB"
- 在 IIS 中 - en-US"
问题是 - IIS 中的哪些设置对此负责,我该如何覆盖它?
Question is - What settings in IIS are responsible for this and how can I override it?
推荐答案
好吧,我实际上并没有找到 IIS 设置负责的内容,但是我在 Application_PreRequestHandlerExecute() 中覆盖了它并且它终于奏效了:
Well, I didn't actually find what IIS setting is responsible, but I've overridden it in Application_PreRequestHandlerExecute() and it finally worked:
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");
这篇关于在 VS 开发服务器和 IIS 上为 ASP.NET MVC 应用程序设置文化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!