Skip to content

Commit

Permalink
Merge pull request #21917 from abpframework/CultureCookiePath
Browse files Browse the repository at this point in the history
Set `.AspNetCore.Culture` cookie `path` to `/`.
  • Loading branch information
realLiangshiwei authored Jan 17, 2025
2 parents c73dbe5 + a960f0a commit b36b09f
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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">
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit b36b09f

Please sign in to comment.