How to add custom hooks to controllers in ASP.NET MVC2
- by Adrian
Hi,
I've just started a new project in ASP.net 4.0 with MVC 2.
What I need to be able to do is have a custom hook at the start and end of each action of the controller.
e.g.
public void Index() {
*** call to the start custom hook to externalfile.cs (is empty so does nothing)
ViewData["welcomeMessage"] = "Hello World";
*** call to the end custom hook to externalfile.cs (changes "Hello World!" to "Hi World")
return View();
}
The View then see welcomeMessage as "Hi World" after being changed in the custom hook.
The custom hook would need to be in an external file and not change the "core" compiled code. This causes a problem as with my limited knowledge ASP.net MVC has to be compiled.
Does anyone have any advice on how this can be achieved?
Thanks