我的ASP.NET MVC5應用程序存在問題。我的應用程序可以設置在瀏覽器中設置的lang/culture(現在只有英文和波蘭文(默認))。我想通過點擊Html.ActionLink讓用戶改變語言/文化。ASP.NET MVC5通過單擊Html.ActionLink更改語言/文化
我創建了一個類:
namespace Guestbook
{
public static class Click
{
public static void SetCulture(string name)
{
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(name);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
}
}
}
而且我有我的觀點:
@Html.ActionLink("PL", "", "Guests", routeValues: null, htmlAttributes: new { onclick = "SetCulture(\"pl\");" })
@Html.ActionLink("EN", "", "Guests", routeValues: null, htmlAttributes: new { onclick = "SetCulture(\"en\");" })
。當然,這是行不通的。我需要更多什麼? JavaScript函數?
可以提供多一些存儲每個用戶的文化信息? – dariogriffo 2014-10-29 11:29:46
正如你所說,我創建了一個控制器並編輯我的視圖,但它在我的應用程序中不起作用。 – Zashi 2014-10-29 12:26:31
請您詳細說明一下嗎?什麼似乎是這個問題?行動是否受到打擊? – Olivier 2014-10-29 12:33:10