Skip to content

UseRequestLocalization() call has to be placed after UseAuthentication() #14221

@joakimriedel

Description

@joakimriedel

I've tried to migrate a net core 2.2 web application to net core 3.0 preview 9. I'm having troubles with middleware, where HttpContext.User.Identity.IsAuthenticated always returns false even if the user is authenticated. To ensure that I do not made any mistakes during migration of our application, I even tried to set up a new 3.0 web application project and follow the instructions on this page. In the code below IsAuthenticated is always false.

How do I make this work in 3.0? I have to check authenticated user to resolve the culture based on a SQL query.

                options.RequestCultureProviders.Insert(0, new CustomRequestCultureProvider(async context =>
                {
                    var isAuthenticated = context.User.Identity.IsAuthenticated; // always false in 3.0 preview9
                    // My custom request culture logic
                    return new ProviderCultureResult("en");
                }));

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions