Created
January 16, 2024 09:42
-
-
Save FacileTechnolab/69570b7fddda47787a34105bc82a207e to your computer and use it in GitHub Desktop.
BlazorAppPart3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Localization; | |
using Microsoft.AspNetCore.Mvc; | |
namespace BlazorAppPart3.Controllers | |
{ | |
[Route("[controller]/[action]")] | |
public class CultureController : Controller | |
{ | |
public IActionResult Set(string culture, string redirectUri) | |
{ | |
if (culture != null) | |
{ | |
var requestCulture = new RequestCulture(culture, culture); | |
var cookieName = CookieRequestCultureProvider.DefaultCookieName; | |
var cookieValue = CookieRequestCultureProvider.MakeCookieValue(requestCulture); | |
HttpContext.Response.Cookies.Append(cookieName, cookieValue); | |
} | |
return LocalRedirect(redirectUri); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment