Filters are a mechanism that ASP.NET Core makes available to apply cross-cutting concerns, such as logging, exception handling, enforcing authorization and authentication, and more. They have been around since the early days of the ASP.NET MVC, but have been augmented in Core.
Filters in ASP.NET Core are an interception mechanism by which we can execute code before, instead of after, a request is processed. Think of them as a way to add custom steps to a pipeline without actually doing so; it remains unchanged but instead, we have finer-grained control over what we are intercepting. They are useful for implementing cross-cutting operations, such as access control, caching, or logging. Here, we will discuss the following: ...