示例代码:
public class CustomAsyncFilter : IAsyncActionFilter { public async Task OnActionExecutionAsync( ActionExecutingContext context, ActionExecutionDelegate next) { // Do some async work here await DoSomethingAsync();
// Call the next middleware in the pipeline
await next();
}
}
示例代码:
[HttpGet]
[CustomAsyncFilter]
public async Task
示例代码:
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddScoped
示例代码:
[HttpGet]
[CustomAsyncFilter]
public async Task