ASP.NET Globalization: Culture=“auto” page directive with neutral culture crash?

别等时光非礼了梦想. 提交于 2019-12-04 04:11:27

First off, you might consider setting UICulture="auto" as well as Culture="auto" in your <%@ Page %> declaration.

Now, I am not seeing this repro on my .NET 4.0 (beta) install, so this might be a product bug in .NET 3.5.

Here's a great resource for learning about neutral cultures and the difference between UICulture and Culture: http://blogs.msdn.com/ddietric/archive/2008/02/05/yacvcp-yet-another-currentculture-vs-currentuiculture-post.aspx

Hope that's helpful.

I was having the same problem and after bonking my head against a wall for a while found the answer right under my nose.

The issue I had was in not understanding the difference between CurrentCulture and CurrentUICulture. The difference being CurrentCulture is used to format dates, numbers and perform sorting, CurrentUICulture is used to lookup culture specific strings from a resource.

I had some code that looked like

return input.ToString("C", System.Globalization.CultureInfo.CurrentUICulture);

when it should be been

return input.ToString("C", System.Globalization.CultureInfo.CurrentCulture);

When you start trying to format culture specific items with a non-specific culture you will get the System.NotSupportedException.

Can't you set the culture on begin request? (Note: asp.net requests can jump between threads so you need to hook into the thread moving as well.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!