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:
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
明显的答案是global.asax中的Application_BeginRequest
和Application_EndRequest
还是我缺少什么?
If you want to hook into page events, you'll probably want to implement your own WebViewPage and WebViewPage classes. Specifically, you'll want to decorate the Execute method. Phil Haack has a blog post on how to do this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.