Localization (culture) issues

Jan 30, 2010 at 7:18 PM

Hi everybody!

I 'm using the MVCSiteMap in a project which should support multiple languages. 

Language changing is working properly without any problems in the views but not in the sitemap.

After searching around i found a similar issue here.  Maarten suggests disabling cache should solve this (and may be my) problem,...but HOW!??  I tried to do it using an Actionfilter like this:

public class NoCache : ActionFilterAttribute, IActionFilter
    {
        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
            filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
            filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
            filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            filterContext.HttpContext.Response.Cache.SetNoStore();

            base.OnResultExecuting(filterContext);
        }

        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            base.OnResultExecuted(filterContext);
        }
    }

and decorating the base controller class with it. The result is this:

  1. the content of the view changes (as it should)
  2. the Html.Menu() method "lags behind" one culture selection( eg suppose i change from default culture en-US to culture de-DE. The content of the view changes but the result of the Html.Menu() still displays in culture en-US. Changing now from culture de-DE to culture ru-RU makes Html.Menu() display the menu in the previous selected culture which is de-DE!!! Changing now from culture ru-RU to culture el-GR makes Html.Menu() display the menu in the previous selected culture which is ru-RU!!!)

How to handle such a situation?

 

Jan 30, 2010 at 7:43 PM

I was using version 1.0. The "new" Version 1.1 (at least the build after 29/1/2010) resolves this issue!