简体   繁体   中英

Asp.net Mvc 2.0 RC Setting Thread CurrentCulture/Ui

I been pulling my hair out all day.

i can't seem to set the current thread cultureui or culture to anything other than English. In the controller i have

  protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);

            CultureInfo cultureInfo = CultureInfo.GetCultureInfo("fr-FR");

            Thread.CurrentThread.CurrentCulture = cultureInfo;
            Thread.CurrentThread.CurrentUICulture = cultureInfo;                    
        }

in my view i have

<%= Thread.CurrentThread.CurrentUICulture.EnglishName%>  

the thread seems to be fine but as soon as the view renders some how its back to english!!

I know its a RC, so is it broken or am I missing something ??

cheers

Johnny

Set the language later. I use a filter that runs before the action (OnActionExecuting).

My first shot at it would be to set it in the action.

Got it working.Bizarrely i just created a new project and started again and it all works fine. All the different ways people have suggested worked in the new project. I have yet to find out what the difference is between the 2 projects.

Cheers

Johnny

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM