为什么Thread.CurrentThread.CurrentCulture.Name显示“en-US”当我的服务器的区域语言设置为英语(英国) [英] Why is Thread.CurrentThread.CurrentCulture.Name showing "en-US" when my server's regional language is set to English (United Kingdom)

查看:1604
本文介绍了为什么Thread.CurrentThread.CurrentCulture.Name显示“en-US”当我的服务器的区域语言设置为英语(英国)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,它在各个点使用户输入日期,并向用户显示日期。调试时(当站点在我们的测试和分段服务器上运行时)日期格式以dd / mm / yyyy格式显示(使用DateTime.ToShortDateString()时)。这些服务器(和我的开发环境都有英语(英国)设置为Windows区域选项下的语言。所有的好,迄今为止,但是在实时服务器日期以mm / dd / yyyy的格式出现,尽管现场服务器仍然将语言设置为English(United Kindgom)。我已经看到这个问题它解释了如何以特定格式解析日期,而且我已经知道如何以所需的字符串格式获取日期( DateTime.ToString(dd / MM / yyyy)),但是我想知道,在实时服务器上的其他操作系统设置是否导致这种差异?
我也看过这个问题,但似乎没有回答我的问题。



一些额外的信息:在开发,测试和分期环境中
Syste m.Threading.Thread.CurrentThread.CurrentUICulture.Name =en-US
System.Threading.Thread.CurrentThread.CurrentCulture.Name =en-GB



在现场环境中
System.Threading.Thread.CurrentThread.CurrentUICulture.Name =en-US
System.Threading.Thread.CurrentThread.CurrentCulture.Name =en-US

解决方案

您是否检查了 > web.config ?



你可以这样声明地设置它:

 < worldwide uiCulture =en-GBculture =en-GB/> 

请参阅: http://msdn.microsoft.com/en-us/library/bz9tc508.aspx


I have a Web Application which at various points makes users enter dates and also displays dates to users. When debugging (and when the site is running on our test and staging servers) the date formats appear in dd/mm/yyyy format (when using DateTime.ToShortDateString()). These servers (and my dev environment have "English (United Kingdom)" set as the language under the windows regional options. All good so far. However, on the live server dates appear in the format mm/dd/yyyy even though the live server still has the language set to "English (United Kindgom)". I've seen this question which explains how to parse the date in a specific format and I already know how to get the date in the required string format (DateTime.ToString("dd/MM/yyyy")) but am wondering what other OS setting on the live server is causing this discrepancy? I've also seen this question, but it doesn't seem to answer my question.

Some additional information: on the dev, test and staging environments System.Threading.Thread.CurrentThread.CurrentUICulture.Name="en-US" System.Threading.Thread.CurrentThread.CurrentCulture.Name="en-GB"

And on the live environment System.Threading.Thread.CurrentThread.CurrentUICulture.Name="en-US" System.Threading.Thread.CurrentThread.CurrentCulture.Name="en-US"

解决方案

Have you checked the globalization section of web.config?

You can set it declaratively like so:

    <globalization uiCulture="en-GB" culture="en-GB" />

See: http://msdn.microsoft.com/en-us/library/bz9tc508.aspx

这篇关于为什么Thread.CurrentThread.CurrentCulture.Name显示“en-US”当我的服务器的区域语言设置为英语(英国)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆