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?