1

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

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);
    }

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

我试图重现这个问题,但它并不总是发生。

谁能指导我为什么会这样!

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

4

0 回答 0