Andrei Neagu
Andrei Neagu

Reputation: 896

Intercept ASP.NET MVC 4 response generation

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:

Upvotes: 0

Views: 1075

Answers (3)

Jarrett Meyer
Jarrett Meyer

Reputation: 19573

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.

Upvotes: 0

Tarzan
Tarzan

Reputation: 4538

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

Upvotes: 1

to StackOverflow
to StackOverflow

Reputation: 124706

The obvious answer would be Application_BeginRequest and Application_EndRequest in global.asax or am I missing something?

Upvotes: 1

Related Questions