我有一个控制器,其OnActionExecuting被重写为异步方法,这种方式:
protected override async void OnActionExecuting(ActionExecutingContext filterContext)
{
}
在该方法内部,我正在调用一些等待的方法,例如await db.Empresa.FindAsync(EmpresaID);
和await UserManager.FindByIdAsync(User.Identity.GetUserId());
因此,我收到错误:ASP.NET Controller: An asynchronous module or handler completed while an asynchronous operation was still pending
。
是否可以将OnActionExecuting
方法设为异步?有没有办法解决这个问题?
Jaime