ASP.NET MVC Multilingual web site

In this article I am going to explain how to handle multiple language in your ASP.NET MVC web site. This a very basic step. Step 1 Create ASP.NET MVC web application Step 2 Add new controller called BaseController. (any name as you wish) override¬†BeginExecuteCore() method. protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state) { string language = “en”; HttpCookie cultureCookie = Request.Cookies[“_culture”]; if (cultureCookie != null) language = cultureCookie.Value; Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(language); return base.BeginExecuteCore(callback, state); } Step 3 Inherit Home Controller from BaseController public class HomeController : BaseController step 4 Add action to change language. To store the culture I have used cookies. It is a simple way. public ActionResult ChangeLanguage(string lang) { HttpCookie cookie = Request.Cookies[“_culture”]; if (cookie != null) cookie.Value = lang; else { cookie = new HttpCookie(“_culture”); cookie.Value = lang; cookie.Expires = DateTime.Now.AddYears(1); } Response.Cookies.Add(cookie); return RedirectToAction(“Index”); } step 5¬† Add resource files. Different languages are stored in resource files. For this demo I have used English, Dutch

read more ASP.NET MVC Multilingual web site