Shared : Presentation Blazor WebAssembly

The Shared.Presentation.BlazorWebAssembly project provides configuration extensions and utilities specific to Blazor WebAssembly applications. It includes helpers for Serilog logging, localization, HttpClient registration with culture propagation, root component mapping, and Web API options with validation.

Dependency Injection

The dependency injection extensions provide configuration helpers for the WebAssembly host builder and host :
  • WebAssemblyHostBuilderExtension : Provides AddSerilog to configure Serilog with a bootstrap console logger, AddLocalization to register localization services and validate the LocalizationOption, AddHttpClient to register a named HttpClient with the Web API base address and a culture message handler, and AddBlazorWebAssembly<TRoutes> to register root components (HeadOutlet and the Routes component).
  • WebAssemblyHostExtension : Provides UseLocalStorageCultureAsync to read the saved culture from browser local storage via JS interop and apply it to the current thread culture, and UseFluentValidationDisplayNameResolver to set a global FluentValidation display name resolver that resolves property names from application and domain resource files with fallback.

Handlers

The CultureHttpMessageHandler is a sealed DelegatingHandler that automatically injects the current culture into the Accept-Language header of every outgoing HTTP request, ensuring the Web API receives the correct culture for localized responses.

Options : Web API

The Web API options define the configuration for the HttpClient used to communicate with the backend API :
  • WebApiOption : A sealed options class that holds the Web API base address, bound from the WebApi configuration section. It also defines the section name and the HttpClient name as constants.
  • WebApiOptionValidator : A FluentValidation validator that ensures the BaseAddress property is not empty.

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.