ASP.NET MVC localization

asp.net-mvclocalization

I'd like to use resource file (.resx) to do localization in ASP.NET MVC. My thought is:

  1. Make a default resource file under App_GlobalResources folder
    Make several local resource files under App_LocalResources folder
  2. read cookie info to set CultureInFo
    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

then, I'd like to use resource file in controller to set ViewData value, something like:

ViewData["Title"] = Resources:Resource, PageTitle;

but the syntax is wrong, how can I do this?

Any idea?

Best Answer

Did you tried following?

ViewData["Title"] = Resources.Resource.PageTitle;

If you have Resource.aspx file in your App_GlobalResources this should work.