Browse Source

Set `.AspNetCore.Culture` cookie `path` to `/`.

pull/21917/head
maliming 1 year ago
parent
commit
4e0037d8fe
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 3
      framework/src/Volo.Abp.AspNetCore.Components.Web/wwwroot/libs/abp/js/abp.js
  2. 15
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor

3
framework/src/Volo.Abp.AspNetCore.Components.Web/wwwroot/libs/abp/js/abp.js

@ -36,6 +36,9 @@ var abp = abp || {};
if (path) {
cookieValue = cookieValue + "; path=" + path;
} else {
cookieValue = cookieValue + "; path=/";
}
if (secure) {

15
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor

@ -1,8 +1,10 @@
@using Volo.Abp.Localization
@using System.Globalization
@using System.Collections.Immutable
@using Volo.Abp.AspNetCore.Components.Web
@inject ILanguageProvider LanguageProvider
@inject IJSRuntime JsRuntime
@inject ICookieService CookieService
@if (_otherLanguages != null && _otherLanguages.Any())
{
<BarDropdown RightAligned="true">
@ -57,20 +59,23 @@
{
await JsRuntime.InvokeVoidAsync(
"localStorage.setItem",
"Abp.SelectedLanguage",
"Abp.SelectedLanguage",
language.UiCultureName
);
await JsRuntime.InvokeVoidAsync(
"localStorage.setItem",
"Abp.IsRtl",
"Abp.IsRtl",
CultureInfo.GetCultureInfo(language.UiCultureName).TextInfo.IsRightToLeft
);
await JsRuntime.InvokeVoidAsync(
"abp.utils.setCookieValue",
await CookieService.SetAsync(
".AspNetCore.Culture",
$"c={language.CultureName}|uic={language.UiCultureName}"
$"c={language.CultureName}|uic={language.UiCultureName}",
new CookieOptions
{
Path = "/"
}
);
await JsRuntime.InvokeVoidAsync("location.reload");

Loading…
Cancel
Save