本文介绍了是否有可能/等待使用异步在MVC 4 AuthorizeAttribute?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到暴露的唯一覆盖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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 08:29
查看更多