Unable to set default and only culture in ASP.Net Core application

I am working on a Polish operating system:

In my class Statup.cs, I have the 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
            });

The full parameters are for reference only so that nothing is installed. In mine _Layout.cshtml, I have the following code:

<div>Current Culture: @CultureInfo.CurrentCulture.DisplayName</div>
<div>Current UI Culture: @CultureInfo.CurrentUICulture.DisplayName</div>

The only supported and accessible culture should be en-GB, however, it is always displayed on the website:

Current Culture: Polski (Polska)
Current UI Culture: Polski (Polska)

I tried to add a package Microsoft.AspNet.Localization, but it does not matter. Based on the code in the localization middleware, everything should work as expected. I am running the latest version of ASP.NET Core 1.0.0.

+4
1

, . UseRequestLocalization UseMvc, .

+5

Source: https://habr.com/ru/post/1648620/


All Articles