我们可以从MVC过滤器进行异步方法调用吗? [英] Can we make async method call from MVC filter?

查看:85
本文介绍了我们可以从MVC过滤器进行异步方法调用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个MVC过滤器。

现在它工作正常,因为我在过滤器中添加了同步代码。

我们可以从过滤器进行异步方法调用吗?



我尝试了什么:



我尝试过异步代码但代码将进入死锁模式。

解决方案

没有可靠的方法可以从过滤器调用 async MVC4或MVC5。



但是,根据您的要求,您可以使用模块加载相关数据:

< a href =https://evandontje.com/2017/08/15/solutions-for-async-await-in-mvc-action-filters/> MVC动作过滤器中异步/等待的解决方案 - Evan Dontje [ ^ ]

I have created one MVC filter.
Right now it is working fine as I have added synchronous code in filter.
Can we make asynchronous method call from filter?

What I have tried:

I have tried with async code but code will go in deadlock mode.

解决方案

There is no reliable way to make async calls from filters in MVC4 or MVC5.

However, depending on your requirements, you might be able to use a module to load the relevant data:
Solutions For Async/Await In MVC Action Filters - Evan Dontje[^]


这篇关于我们可以从MVC过滤器进行异步方法调用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆