本文介绍了ASP.NET Core中的Thread.CurrentThread.CurrentUICulture的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的MVC应用程序中,我有以下一行,并且运行良好.

In my MVC application I have had the following line and it has worked fine.

if (Thread.CurrentThread.CurrentUICulture.Name == localizationItem.CultureInfo.Trim())

现在,当我将应用程序移植到.Net Core 1.1时, CurrentUICulture 似乎已经消失了.关于替换它的任何想法是什么?

Now as I am porting my application over to .Net Core 1.1, it appears that CurrentUICulture has went missing in action. Any ideas on what it's replacement is?

推荐答案

我相信您正在寻求本地化.

I believe you're looking to do localization.

此处有关如何操作它

设置完成后,您可以使用类似的方式为用户获取当前的区域性:

Once it's setup, you can use something like this to get the current culture for a user:

var rqf = Request.HttpContext.Features.Get<IRequestCultureFeature>();
var culture = rqf.RequestCulture.Culture;

这篇关于ASP.NET Core中的Thread.CurrentThread.CurrentUICulture的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 17:37