Cannot set default and only culture in ASP.Net Core app

Marcin

I'm working on Polish operating system:

In my Statup.csclass 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
            });

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>

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)

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.

Marcin

There is one important thing, not mentioned in documentation. UseRequestLocalization has to be placed before UseMvc, mine was below.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Cannot set default and only culture in ASP.Net Core app

From Dev

Where does the default culture get set in a .NET application

From Dev

Cannot set namespace provider to false in Asp.net core project

From Dev

Cannot connect ASP.NET Core web app with Application Insights

From Dev

Cannot launch asp.net core web app in IIS Express

From Dev

Enabling Client-Based Culture in Asp.Net Core

From Dev

ASP.NET Core MVC default routing

From Dev

How to set default build number in .Net Core

From Dev

How to set default page asp.net

From Dev

How to set default parameter in ASP.NET

From Dev

ASP.NET Core app with "user-secrets" fails on macOS command line only

From Dev

Optionally override request culture via url/route in an ASP.NET Core 1.0 Application

From Dev

Cannot deploy asp.net core project?

From Dev

How to change asp.net mvc5 web app current localization culture with refreshing the same page?

From Dev

Difference between using the ASP.NET Core Web Application (.NET Core) with net461 set as the only framework and using the (.NET Framework) template

From Dev

How do I set a default static page for a ASP.Net Core Web API Project when start debug in VS2015?

From Dev

Odd Culture behaviour on ASP.Net forms

From Dev

Asp.Net MVC DateTime culture issue

From Dev

Cannot delete SMS programatically (Default SMS app set)

From Dev

Cannot set a Windows 10 Store App as default program to open a file

From Dev

ASP.NET Core Default debugging launch URL

From Dev

What are the Default, System and Microsoft LogLevels in ASP.NET Core

From Dev

Default Values for ASP.NET Core TagHelper Properties

From Dev

How to add a URL parameter by default in ASP.NET Core

From Dev

Default Values for ASP.NET Core TagHelper Properties

From Dev

What are the Default, System and Microsoft LogLevels in ASP.NET Core

From Dev

ASP.NET Core route with constraint is not falling back to default route

From Dev

ASP.NET BoilerPlate: .Net core template - app service error

From Dev

ASP.NET MVC Missing Default Action only for one controller

Related Related

  1. 1

    Cannot set default and only culture in ASP.Net Core app

  2. 2

    Where does the default culture get set in a .NET application

  3. 3

    Cannot set namespace provider to false in Asp.net core project

  4. 4

    Cannot connect ASP.NET Core web app with Application Insights

  5. 5

    Cannot launch asp.net core web app in IIS Express

  6. 6

    Enabling Client-Based Culture in Asp.Net Core

  7. 7

    ASP.NET Core MVC default routing

  8. 8

    How to set default build number in .Net Core

  9. 9

    How to set default page asp.net

  10. 10

    How to set default parameter in ASP.NET

  11. 11

    ASP.NET Core app with "user-secrets" fails on macOS command line only

  12. 12

    Optionally override request culture via url/route in an ASP.NET Core 1.0 Application

  13. 13

    Cannot deploy asp.net core project?

  14. 14

    How to change asp.net mvc5 web app current localization culture with refreshing the same page?

  15. 15

    Difference between using the ASP.NET Core Web Application (.NET Core) with net461 set as the only framework and using the (.NET Framework) template

  16. 16

    How do I set a default static page for a ASP.Net Core Web API Project when start debug in VS2015?

  17. 17

    Odd Culture behaviour on ASP.Net forms

  18. 18

    Asp.Net MVC DateTime culture issue

  19. 19

    Cannot delete SMS programatically (Default SMS app set)

  20. 20

    Cannot set a Windows 10 Store App as default program to open a file

  21. 21

    ASP.NET Core Default debugging launch URL

  22. 22

    What are the Default, System and Microsoft LogLevels in ASP.NET Core

  23. 23

    Default Values for ASP.NET Core TagHelper Properties

  24. 24

    How to add a URL parameter by default in ASP.NET Core

  25. 25

    Default Values for ASP.NET Core TagHelper Properties

  26. 26

    What are the Default, System and Microsoft LogLevels in ASP.NET Core

  27. 27

    ASP.NET Core route with constraint is not falling back to default route

  28. 28

    ASP.NET BoilerPlate: .Net core template - app service error

  29. 29

    ASP.NET MVC Missing Default Action only for one controller

HotTag

Archive