问题描述
我正在研究波兰操作系统:
I'm working on Polish operating system:
在我的Statup.cs
课堂上,我有以下代码
In my Statup.cs
class I have following code
// Configure the localization options
var supportedCultures = new[]
{
new CultureInfo("en-GB")
};
app.UseRequestLocalization(
new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-GB"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures,
FallBackToParentCultures = true,
FallBackToParentUICultures = true,
RequestCultureProviders = null
});
完整选项仅供参考,以确保未设置任何内容.在我的_Layout.cshtml
中,我有以下代码:
The full options are for reference only to be sure that nothing is set behind. In my _Layout.cshtml
I have following code:
<div>Current Culture: @CultureInfo.CurrentCulture.DisplayName</div>
<div>Current UI Culture: @CultureInfo.CurrentUICulture.DisplayName</div>
唯一受支持和可用的区域性应该是en-GB
,但是在网站上始终显示:
The only supported and available culture should be en-GB
, however on web site it is always showing:
Current Culture: Polski (Polska)
Current UI Culture: Polski (Polska)
我尝试添加Microsoft.AspNet.Localization
程序包,但这没什么区别.基于本地化中间件中的代码,所有工具均应按预期工作.我正在运行最新版本的ASP.NET Core 1.0.0.
I've tried to add Microsoft.AspNet.Localization
package, but it makes no difference. Based on code in localization middleware, all should work as expected. I'm running latest version of ASP.NET Core 1.0.0.
推荐答案
有一件重要的事情,文档中没有提到. UseRequestLocalization
必须放在UseMvc
之前,我的位置在下面.
There is one important thing, not mentioned in documentation. UseRequestLocalization
has to be placed before UseMvc
, mine was below.
这篇关于无法在ASP.Net Core应用中设置默认和唯一区域性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!