I have an action filter that when used in certain specific conditions has to perform a web service call to ensure that the current state is valid. This initially seemed like an ideal candidate for async/await, but I have encountered a snag:
Assume a request to: /Test/FilteredAction
- MyCustomActionFilter begins executing
- The first "await" statement is reached
- TestController.FilteredAction starts executing
- MyCustomActionFilter resumes executing
Traditionally I would expect the action filter to resume executing and then complete before the controller action starts executing, but this does not happen.
Now I assume this is because I am using:
public class MyCustomActionFilter : ActionFilterAttribute
{
public override **async** void OnActionExecuting(FilterContext context)
{
var foo = await WebServiceCall();
}
}
So I think my question is: Is there an async-aware action filter class built into MVC 4, or should I just block on the calls in here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…