改变文化时不要改变资源

时间:2019-08-11 08:58:36

标签: asp.net-mvc model-view-controller

我有两个项目的解决方案,资源和主项目。

我将resource.dll和文件夹添加到主项目。但是当我改变文化时,它将获得默认资源。

public class LanguageController : Controller
{
 // GET: Language
 public ActionResult Change(string lan, string url)
  {
    if (lan != null)
     {
      Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lan);
      Thread.CurrentThread.CurrentUICulture = new CultureInfo(lan);
     }

     HttpCookie cookie = new HttpCookie("language");
     cookie.Value = lan;
     Response.Cookies.Add(cookie);

     return Redirect(url);
  }

}

0 个答案:

没有答案