Skip to content

Instantly share code, notes, and snippets.

@FacileTechnolab
Created January 16, 2024 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FacileTechnolab/69570b7fddda47787a34105bc82a207e to your computer and use it in GitHub Desktop.
Save FacileTechnolab/69570b7fddda47787a34105bc82a207e to your computer and use it in GitHub Desktop.
BlazorAppPart3
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