Blog Logo
TAGS

ASP.NET Core 7: Introducing endpoint filters, actions filters for minimal APIs

ASP.NET Core 7 introduces endpoint filters, actions filters for minimal APIs. It allows defining any operation before and after the minimal endpoint is executed. The basic filter requires the injection dependency to access the GetRequiredService method from HttpContext.RequestServices object to get an instance of a service. Also, ASP.NET Core 7 allows writing custom endpoint filters. A class should be written that implements the IEndpointFilter interface and writes a custom async ValueTask InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next) method. You can use injection dependency by constructor in such custom filters. Anthony Giretti is a specialist in web technologies, particularly Microsoft .NET and learns the Cloud Azure platform.