是否可以在 MVC 4 AuthorizeAttribute 中使用 async/await? [英] Is it possible to use async/await in MVC 4 AuthorizeAttribute?
问题描述
我在 MVC 的 AuthorizeAttribute
上看到的唯一覆盖是 public override void OnAuthorization( AuthorizationContext filterContext )
它不适合与 async/await 一起使用,因为它不返回一个 Task
.是否有另一种方法可以在 MVC 中创建允许使用 async/await 的 AuthorizeAttribute
?
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 上宣布的 ASP.NET "vNext" 将支持 MVC 的异步过滤器.
However, ASP.NET "vNext", announced at TechEd this week, will support asynchronous filters for MVC.
这篇关于是否可以在 MVC 4 AuthorizeAttribute 中使用 async/await?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!