ASP.NET Resource Manager RaceCondition in Multilingual Application

点点圈 提交于 2019-12-08 06:28:16

问题


We're using resource manager to load resources based on Thread UI culture in an ASP.NET MVC 4 application.We set thread culture as below:

protected void Application_AcquireRequestState(object sender, EventArgs e) {
    var lang = HttpContext.Current.Request.RequestContext.RouteData.Values["lang"];
    var ci = new CultureInfo(lang);
    var culture = CultureInfo.CreateSpecificCulture(ci.Name);
    culture.DateTimeFormat.AMDesignator = "AM";
    culture.DateTimeFormat.PMDesignator = "PM";
    Thread.CurrentThread.CurrentUICulture = culture;
    Thread.CurrentThread.CurrentCulture = culture;
}

We think there is a RaceCondition problem in resource manager that cause loading resources with invalid UI Culture for current thread,For example we see that CurrentUICulture and CurrentCulture is en-US but loaded resources are in it-IT.This happen often when application is under load.We did a research about this and find these threads:

ASP.Net MVC resource files are sometimes incorrectly loaded by the ResouceManager

https://connect.microsoft.com/VisualStudio/feedbackdetail/view/806505/race-condition-in-system-resources-resourcemanager-leads-to-incorrect-resources-being-loaded

we did every thing mentioned in the two above links but nothing change,We are now so tired.Special thanks to Any one can help around this?

来源:https://stackoverflow.com/questions/32672367/asp-net-resource-manager-racecondition-in-multilingual-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!