0
我創建了乾淨的APS.NET MVC 4項目,我嘗試使用this教程進行國際化。HomeController從BaseController繼承,但沒有在BaseController中運行函數
我有使用baseController的問題,因爲當我運行項目時,從基礎控制器的功能不執行。也許我忘了執行什麼......
BaseController
public class BaseController : Controller
{
protected override void ExecuteCore()
{
string cultureName = null;
//Attempt to read the culture cookie from Request
HttpCookie cultureCookie = Request.Cookies["_culture"];
if (cultureCookie != null)
cultureName = cultureCookie.Value;
else
cultureName = Request.UserLanguages[0]; //obtain it from HTTP
//Validation culture name
cultureName = CultureHelper.GetImplementedCulture(cultureName); // This is safe
//Modify current thread's cultures
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cultureName);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
base.ExecuteCore();
}
}
的HomeController
public class HomeController : BaseController
{
public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
return View();
}
}