Filters are a great, often underutilized feature of ASP.NET MVC and ASP.NET Core MVC. They provide a way to hook into the MVC action invocation pipeline, which makes them ideal for pulling common repetitive tasks out of your actions. Often, an app will have a standard policy that it applies to how it handles certain conditions, especially those that might generate particular HTTP status codes. Or it might perform error handling or application-level logging in a specific fashion, in every action. These kinds of policies represent cross-cutting concerns, and if possible, you want to follow the Don’t Repeat Yourself (DRY) principle and pull them out into a common abstraction. Then, you can apply this abstraction globally or wherever appropriate within your application. Filters provide an elegant way to achieve this.
Read more in my latest MSDN feature: ASP.NET Core – Real-World ASP.NET Core MVC Filters.