Filters
Filters allow code to run before or after specific stages in the request processing pipeline.
Filter types
Authorization Filters
Run first
Determine whether the user is authorized for the request. If not, Short-circuit the pipeline.
Resource Filter
Runs after authorization.
OnResourceExecuting
runs code before the rest of the filter pipeline. For example, before model binding.OnResourceExecuted
runs code after the rest of the pipeline has completed.
Action/Endpoint Filters
Runs immediately before and after an action method is called.
Can change the arguments passed/result returned into/from an action.
Not supported in Razor pages.
Can be invoked on both actions and route handler-based endpoints.
Synchronous Action Filters
Asynchronous Action Filteres
Built-in Filter Attributes
ActionFilterAttribute
ExceptionFilterAttribute
ResultFilterAttribute
FormatFilterAttribute
ServiceFilterAttribute
Last updated