OwinMiddleware不会保留.net 4.6中的文化更改.*

编程入门 行业动态 更新时间:2024-10-26 10:34:43
本文介绍了OwinMiddleware不会保留 4.6中的文化更改.*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个很简单的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); } }

我将中间件附加到执行的管道上,但是当我调用一个动作时,控制器就没有文化了(就像在 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 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 :-(

connect.microsoft/VisualStudio/feedback/details/2455357

推荐答案

我收到了适用于我的Microsoft的回复.

I got a response from microsoft which works for me.

您可以尝试在web.config文件中设置以下元素.这 元素必须是<appSettings>元素的子元素.

you can try set the following element in your web.config file. This element has to be child to the <appSettings> element.

<add key="appContext.SetSwitch:Switch.System.Globalization.NoAsyncCurrentCulture" value="true" />

更多推荐

OwinMiddleware不会保留.net 4.6中的文化更改.*

本文发布于:2023-11-10 03:01:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574165.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文化   OwinMiddleware   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!