What I need to do is execute some code before the MVC executes the controller and after it finishes generating the View.
Is there any way to do this?
I need to integrate the MVC application with an existing cache system, so:
- before executing the controller, instantiate a cache.
- after the view was generated, destroy the cache.
Action Filter Attributes enable you to inject code interceptors into the request of a MVC controller that can execute before and after a Controller or its Action methods execute.
For more detail, see: Understanding Filter Interceptors by Scott Guthrie