Skip to content

Statically set the server-side culture: Where to add app.UseRequestLocalization #33847

@Schoof-T

Description

@Schoof-T

Issue description

In my Blazor Server application I'm trying to statically set the culture for every user (to en-GB). I found the following guidance: https://learn.microsoft.com/en-us/aspnet/core/blazor/globalization-localization?view=aspnetcore-8.0#statically-set-the-server-side-culture

However it is not clear to me where to add app.UseRequestLocalization("en-GB");. The document says "immediately after Routing Middleware". But as far as I can see Blazor Server does not add any Routing Middleware?

Below is the whole Program.cs from the Template:

using BlazorApp2.Components;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error", createScopeForErrors: true);
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();

app.UseStaticFiles();
app.UseAntiforgery();

app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode();

app.Run();

I am also hosting the application in IIS, having set the Application Pool as follows:
Image

The Identity is a an account, with limited access.

What is your recommendation?

Software versions

Check the .NET target framework(s) being used, and include the version number(s).

  • .NET Core
  • .NET 5.0 or later
  • .NET Framework
  • .NET Standard

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions