首页 > 代码库 > asp.net中MVC多语言包的使用
asp.net中MVC多语言包的使用
Global.asax.cs文件
protected void Application_AcquireRequestState(object sender, EventArgs e)
{
if (HttpContext.Current.Session != null)
{
if (this.Session["language"] == null string.IsNullOrWhiteSpace(this.Session["language"].ToString()))
{
Session["language"] = "zh-CN";
}
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Session["language"].ToString());
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(Session["language"].ToString());
}
}
登录页面
if (Session["language"] == null)
{
Session["language"] = "zh-CN";
}
else if (Session["language"].Equals("en-US"))
{
Session["language"] = "zh-CN";
}
else
{
Session["language"] = "en-US";
}
asp.net中MVC多语言包的使用