Filters come in handy when we wish to build cross-cutting concepts in the MVC stack of ASP.NET Core. They are useful when we wish to implement features such as authorization or caching. ASP.NET Core provides some out-of-the-box filter types. Each of these can be used for a specific purpose in our service:
Filter type | Type description |
Authorization |
This kind of filter is related to the authorization of users. It is the first filter that's executed in the filter pipeline and can short-circuit the pipeline of requests. |
Resource |
Resource filters run immediately after authorization filters and after the rest of the pipeline has completed. They're useful when we wish to implement caching or for performance implementations. |
Action |
Action filters are focused on the life cycle of action methods. They intercept and change the arguments and... |