资源文化价值自动变化

时间:2015-03-30 08:33:26

标签: asp.net asp.net-mvc-5 culture uiculture

我在我的应用程序中使用资源文件。 在基本控制器中,我定义了我的应用程序文化,如下所示

protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
    {

        string cultureName = RouteData.Values["culture"] as string; 

        CultureInfo culture = null;


        HttpCookie cultureCookie = Request.Cookies["_culture"];
        if (cultureCookie != null)
            cultureName = "de-CH"; 
        else
            cultureName = "de-CH"; 
        // Validate culture name
        cultureName = CultureHelper.GetImplementedCulture(cultureName); 

        // Modify current thread's cultures            
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cultureName);
        Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cultureName);
        System.Globalization.CultureInfo.DefaultThreadCurrentCulture = Thread.CurrentThread.CurrentCulture;
        System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = Thread.CurrentThread.CurrentCulture;      
        return base.BeginExecuteCore(callback, state);
    }

但有时,如果系统闲置几分钟,应用程序文化会自动更改为英语。

我试图重新创建这个问题,但不是alwats正在发生。

任何人都可以指导我为什么会这样!

我没有为文化设置任何到期值。

0 个答案:

没有答案