December 2019
Intermediate to advanced
510 pages
11h 33m
English
Filters support both asynchronous and synchronous behaviors. As we saw in the previous example, CustomActionFilter implements two synchronous methods: OnActionExecuting and OnActionExecuted. In the case of an asynchronous filter, the implementation is different:
using System.Threading.Tasks;using Microsoft.AspNetCore.Mvc.Filters;namespace SampleAPI.Filters{ public class CustomActionFilterAsync : IAsyncActionFilter { public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { //Before var resultContext = await next(); //After } }}
CustomActionFilterAsync implements the async version of the action filter class, that is, IAsyncActionFilter, and implements only one method, ...
Read now
Unlock full access