1
In my Controller Home, I have this:
/// <summary>
/// Aqui estou trocando o idioma da página de acordo cam a seleção do
/// usuário.
/// </summary>
///
public ActionResult AlteraIdioma(string LinguagemAbreviada)
{
if (LinguagemAbreviada != null)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(LinguagemAbreviada);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(LinguagemAbreviada);
}
//aqui estou gravando o cookie com o idioma para que seja recuperado no Global.asax
HttpCookie cookie = new HttpCookie("Linguagem");
cookie.Value = LinguagemAbreviada;
Response.Cookies.Add(cookie);
return View("Index");
}
It changes the language of the page and records a cookie for the navigation to follow in the chosen language, but I wonder if I can call this in all controllers without having to repeat, how would it look? Thanks
I don’t know what the doubt is. Power can, but it depends on what you want to do, if you really need it, if that’s how it should be. It would probably be better to do it another way, but it’s not easy to give an example without a context. The basic thing is that you should just take the cookie and do what you want without calling this method. It can, but it would not make sense to do it. I have doubts until this method is right. By the way, I noticed that you accept anything that comes on the server, right? http://answall.com/q/13298/101
– Maniero