这是因为zh-CHS是中立文化 . 在ASP.NET 2.0中,无法将CurrentCulture设置为中性文化,如zh-CHS . 但是你可以将它设置为像zh-CN这样的特定文化 . 如果您需要使用中性文化,例如zh-CHS,则可以设置CurrentUICulture属性 . CurrentUICulture负责从资源文件中获取文本 . CurrentCulture负责Number,DateTime和Currency格式 .
顺便说一句,在ASP.NET 4.0中,您可以将CurrentCulture设置为中性文化,但不能在v2.0中设置 . 在我的代码中,站点可以在.NET 2或.NET 4上运行,我这样做:
public static void SetCurrentCulture(string cultureName)
{
try
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureName);
}
catch (Exception)
{
// Ignore if exception happens: In ASP.NET 2.0 setting CurrentCulture = Neutral culture (like zh-CHS) throws an exception:
// Culture 'zh-CHS' is a neutral culture. It cannot be used in formatting and parsing and therefore cannot be set as the thread's current culture.
}
Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName);
HttpCookie cultureCookie = new HttpCookie("CultureCookie", cultureName);
HttpContext.Current.Response.Cookies.Set(cultureCookie);
}