diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/wwwroot/libs/abp/js/abp.js b/framework/src/Volo.Abp.AspNetCore.Components.Web/wwwroot/libs/abp/js/abp.js index 51ff0151b6..ef9d6d6103 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/wwwroot/libs/abp/js/abp.js +++ b/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) { diff --git a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor b/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor index 01cd632615..7814000136 100644 --- a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor +++ b/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()) { @@ -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");