问题描述
我看到暴露的唯一覆盖MVC的 AuthorizeAttribute
是公共覆盖无效OnAuthorization(AuthorizationContext filterContext)
这是不适用于异步/等待使用,因为它不返回工作
。有另一种方式在MVC中创建一个 AuthorizeAttribute
,允许使用异步电动机/ AWAIT?
The only override I see exposed on MVC's AuthorizeAttribute
is public override void OnAuthorization( AuthorizationContext filterContext )
which is not suitable for use with async/await because it doesn't return a Task
. Is there another way to create an AuthorizeAttribute
in MVC that allows the use of async/await?
推荐答案
ASP.NET MVC今天不支持异步过滤器。 。
ASP.NET MVC today does not support asynchronous filters. Please vote.
不过,,在TechEd本周宣布,将支持异步过滤器的MVC。
However, ASP.NET "vNext", announced at TechEd this week, will support asynchronous filters for MVC.
这篇关于是否有可能/等待使用异步在MVC 4 AuthorizeAttribute?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!