问题描述
我有一个很简单的owin文化中间件.
I have an owin culture middle ware running very nice.
它只是根据URL更改区域性.完全适用于4.5.*.现在,当将全形文字更改为4.6.1时,不再保留该区域性,结果它就无法正常工作.
It just changes the culture according to the url. This works in 4.5.* perfectly. Now when the runtiome is changed to 4.6.1, the culture isn't preserved anymore and as a result it just doesn't work.
我可以通过一个非常简单的解决方案来重现它,该解决方案仅具有此中间件来模拟文化变化
I can reproduce it in a very simple solution which only has this middleware simulating the culture change
public class CultureMiddleware : OwinMiddleware
{
public CultureMiddleware(OwinMiddleware next)
: base(next)
{
}
public override async Task Invoke(IOwinContext context)
{
var culture = new CultureInfo("es-ES");
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
CultureInfo.CurrentCulture = culture;
CultureInfo.CurrentUICulture = culture;
await Next.Invoke(context);
}
}
我将中间件附加到执行的管道上,但是当我调用一个动作时,控制器就没有文化了(就像在.net 4.5.1中一样)
I attach the middleware to the pipeline it gets execute but when I'm calling an action the controller doesn't have the culture (like it had in .net 4.5.1)
我已经在这里发布了,但是支持真的很慢.每两周一个答案,然后好像他们还没有尝试过他们写的东西:-(
I already posted here but the support is really slow. One Answer every two weeks and then it seems like they haven't tried what they write :-(
https://connect.microsoft.com/VisualStudio/feedback/details/2455357
推荐答案
我收到了适用于我的Microsoft的回复.
I got a response from microsoft which works for me.
<add key="appContext.SetSwitch:Switch.System.Globalization.NoAsyncCurrentCulture" value="true" />
这篇关于OwinMiddleware不会保留.net 4.6中的文化更改.*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!