diff --git a/src/BootstrapBlazor.Server/Components/Components/CultureChooser.razor.cs b/src/BootstrapBlazor.Server/Components/Components/CultureChooser.razor.cs index 9569f95ff37..09fcfa9dc3a 100644 --- a/src/BootstrapBlazor.Server/Components/Components/CultureChooser.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Components/CultureChooser.razor.cs @@ -68,7 +68,7 @@ private async Task SetCulture(SelectedItem item) if (SelectedCulture != item.Value) { var culture = item.Value; - var uri = new Uri(NavigationManager.Uri).GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped); + var uri = new Uri(NavigationManager.Uri).GetComponents(UriComponents.PathAndQuery, UriFormat.SafeUnescaped); var query = $"?culture={Uri.EscapeDataString(culture)}&redirectUri={Uri.EscapeDataString(uri)}"; // use a path that matches your culture redirect controller from the previous steps diff --git a/src/BootstrapBlazor.Server/Components/Layout/HomeLayout.razor.cs b/src/BootstrapBlazor.Server/Components/Layout/HomeLayout.razor.cs index 429a07260ad..8d8834185c7 100644 --- a/src/BootstrapBlazor.Server/Components/Layout/HomeLayout.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Layout/HomeLayout.razor.cs @@ -96,7 +96,7 @@ private Task SetLang(string cultureName) // 使用 api 方式 适用于 Server-Side 模式 if (SelectedCulture != cultureName) { - var uri = new Uri(NavigationManager.Uri).GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped); + var uri = new Uri(NavigationManager.Uri).GetComponents(UriComponents.PathAndQuery, UriFormat.SafeUnescaped); var query = $"?culture={Uri.EscapeDataString(cultureName)}&redirectUri={Uri.EscapeDataString(uri)}"; // use a path that matches your culture redirect controller from the previous steps diff --git a/src/BootstrapBlazor.Server/Components/Pages/Localization.razor b/src/BootstrapBlazor.Server/Components/Pages/Localization.razor index 2e66b96f35f..b18a0e88c7d 100644 --- a/src/BootstrapBlazor.Server/Components/Pages/Localization.razor +++ b/src/BootstrapBlazor.Server/Components/Pages/Localization.razor @@ -184,7 +184,7 @@ public class CultureController : Controller if (SelectedCulture != item.Value) { var culture = item.Value; - var uri = new Uri(NavigationManager.Uri).GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped); + var uri = new Uri(NavigationManager.Uri).GetComponents(UriComponents.PathAndQuery, UriFormat.SafeUnescaped); var query = $"?culture={Uri.EscapeDataString(culture)}&redirectUri={Uri.EscapeDataString(uri)}"; // use a path that matches your culture redirect controller from the previous steps