Real World ASPNET Core MVC Filters
Date Published: 08 August 2016
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.
You can also check out my article in the official ASP.NET Core docs on ASP.NET MVC Core Filters.
Category - Browse all categories
About Ardalis
Software Architect
Steve is an experienced software architect and trainer, focusing on code quality and Domain-Driven Design with .NET.