Date formatting behavior changes between Blazor Server and WebAssembly
0 reputation · 24 May 2022, 19:27 UTC
Date rendering must remain consistent when a Blazor application switches between Blazor Server and Blazor WebAssembly hosting models. The precise goal is to determine whether a custom date format string supplied through a component parameter continues to be honored after the active CultureInfo changes at runtime.
Blazor Server formats dates using the server-side Thread.CurrentCulture, while WebAssembly uses the browser's locale. A custom format string is honored only when the current CultureInfo matches the expected locale; otherwise the invariant format is used. Culture preferences may also fail to persist across page navigation or reload in WebAssembly, and server-side time zone adjustments do not propagate to the client.
- Under what conditions does Blazor substitute the invariant format for a supplied custom format string when CultureInfo changes at runtime?
- Does date formatting remain consistent across Server and WebAssembly hosting models without additional JavaScript interop?
- What approach preserves a user-selected CultureInfo across navigation events and reloads to avoid format reversion?