►► Master Web API development Best Practices:
►► Build great web apps in Blazor WebAssembly:
►► Support us on Patreon and get the source code:
In this video, we are going to learn how to use Action Filters in ASP.NET Core applications to create readable and maintainable actions.
LINKS MENTIONED IN THE VIDEO:
To visit the whole article and download the source code visit:
►►
To watch the Global Error Handling video, visit:
►►
To visit our site:
►►
FOLLOW US ON SOCIAL MEDIA!
►►
►►
►►
VIDEO SUMMARY:
Filters in .NET offer a great way to hook into the MVC action invocation pipeline. Therefore, we can use filters to extract code that can be reused and make our actions cleaner and maintainable. Some filters are already provided by ASP.NET Core like the authorization filter, and there are the custom ones that we can create ourselves.
There are different filter types:
Authorization filters – They run first to determine whether a user is authorized for the current request
Resource filters – They run right after the authorization filters and are very useful for caching and performance
Action filters – They run right before and after the action method execution
Exception filters – They are used to handle exceptions before the response body is populated
Result filters – They run before and after the execution of the action methods result.
In this video, we are going to talk about Action filters and how to use them to create cleaner and reusable code in our Web API.