I need to apply a filter to the request. I created a subclass of ActionFilterAttribute
with overrided OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
. I have a bit sophisticated logic inside the filter and in some cases I must stop the running of the filter and return default action result (as if there were no filter). If I return
in the filter, workflow seems to stop completely, no action result returns. I tried to await next()
or call base.OnActionExecutionAsync(...)
, but that didn't work. How can I implement returning from filter?
I have something like this:
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
//some logic
if (questionnaireId == Guid.Empty)
{
//here I need to let the mvc action run normally
return;//it doesn't work
} else {
//some logic..
}
}
for returning default result add await base.OnActionExecutionAsync(context, next)
;
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
//some logic
if (questionnaireId == Guid.Empty)
await base.OnActionExecutionAsync(context, next);
else {
//some logic..
}
}