In resource filters, you can apply similar logic as authorization filters but it executes slightly after the authorization filters, and you have more information. For example, when resource filters execute, the user has already logged in (if using authentication). Some common uses for resource filters are the following:
- Logging
- Caching
- Throttling
- Modifying model binding
The IResourceFilter interface defines two methods:
- OnResourceExecuting: Called before the request reaches the action
- OnResourceExecuted: Called after the action is executed
Each of these methods takes a single parameter of the ResourceExecutingContext and ResourceExecutedContext types for pre-events and post-events, respectively.ResourceExecutingContextoffers the following properties, which reflect the context prior to the resource being processed:
- Result (IActionResult...