Hi,
Thanks to Sherry Chen's help in this thread I've managed to get my page changing culture based on the cookie the user has set. At least I thought so as I checked this only in Firefox browser. Having published my page I discovered that his functionality doesn't work in Chrome and IE (haven't tested other browsers). I checked and in all browser the cookie IS created and it contains correct value etc., but only in Firefox it effects in changing the culture. Here's the method that's creating the cookie:
public async Task<IActionResult> OnGetSetCultureAsync(string culture) { HttpContext.Response.Cookies.Append("Culture", "c=" + culture + "|uic=" + culture, new Microsoft.AspNetCore.Http.CookieOptions { Expires = DateTimeOffset.Now.AddMonths(3) }); var returnUrl = Request.Headers["Referer"].ToString(); if (returnUrl.Contains("?culture=")) { var url = returnUrl.Substring(0, returnUrl.IndexOf("?culture=")); return Redirect(url + "?culture=" + culture); } else { return Redirect(returnUrl + "?culture=" + culture); } }
Here's a github repository for the project. And my page is currently publishedhere, so you can test it there. Any help will be appreciated.
Regards,
Robert