Skip to content
This repository was archived by the owner on Nov 29, 2018. It is now read-only.
This repository was archived by the owner on Nov 29, 2018. It is now read-only.

Where in the middleware should app.UseRequestLocalization() be called? #136

@jerriep

Description

@jerriep

I have an application which uses the localization middleware. Previously I would call app.UseRequestLocalization() very early in the Configure method:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    loggerFactory.MinimumLevel = LogLevel.Information;
    loggerFactory.AddConsole();
    loggerFactory.AddDebug();

   app.UseRequestLocalization();

   // Rest of the method...
}

But I have written a custom RequestCultureProvider which read the culture from the user info. Well actually it reads it from a claim on the ClaimsPrincipal (i.e. HttpContext.User property).

Thing is however that if put the call to app.UseRequestLocalization() early in the methodm the user is not set because the Identity middleware has not executed yet. So I need to move it to somewhere after the call to app.UseIdentity(), then all works fine.

I am curious however whether there will be some sort of obviously bad side effect I may suffer when moving the Localization middleware further down the middleware pipeline?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions