Understanding Filters

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: ...

Get Modern Web Development with ASP.NET Core 3 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.