A resource filter intercepts ASP.NET Core MVC requests around endpoint execution. It runs before model binding, then resumes after the endpoint has handled the request but before the action result executes. This makes it useful for changing requests, changing responses, or stopping the pipeline early. section 30.3 section 30.4.2
Use a resource filter when you need to:
- Short-circuit processing by assigning an IActionResult to ResourceExecutingContext.Result. section 30.4.2
- Implement request-level features such as caching, before model binding and endpoint work occur. section 30.3 section 30.4.2
- Inspect the eventual action result, cancellation state, or exception through ResourceExecutedContext. section 30.4.2
A simple path-based cache
A SimpleCacheAttribute can implement IResourceFilter, use the request PathString as a dictionary key, and assign a previously stored IActionResult to context.Result when a cached entry exists. Otherwise, the endpoint runs and OnResourceExecuted can store its result. Applied alongside [RequireHttps] on a Razor Page model, the filter demonstrates reusable caching at the endpoint boundary.
Table 30.2 The filter types (view table figure)
| Name |
Description |
|---|---|
| Authorization filters |
This type of filter is used to apply the application’s authorization policy. |
| Resource filters |
This type of filter is used to intercept requests, typically to implement features such as caching. |
| Action filters |
This type of filter is used to modify the request before it is received by an action method or to modify the action result after it has been produced. This type of filter can be applied only to controllers and actions. |
| Page filters |
This type of filter is used to modify the request before it is received by a Razor Page handler method or to modify the action result after it has been produced. This type of filter can be applied only to Razor Pages. |
| Result filters |
This type of filter is used to alter the action result before it is executed or to modify the result after execution. |
| Exception filters |
This type of filter is used to handle exceptions that occur during the execution of the action method or page handler. |
Compare resource filters with authorization, action, page, result, and exception filters to choose the pipeline stage that matches the feature. section 30.3

