【发布时间】:2013-04-07 06:06:28
【问题描述】:
我刚刚在 ASP.net 4.0 中使用 MVC 2 启动了一个新项目。
我需要做的是在控制器的每个动作的开始和结束处都有一个自定义钩子。
例如
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();
}
在自定义钩子中更改后,视图会将welcomeMessage 视为“Hi World”。
自定义挂钩需要位于外部文件中,并且不能更改“核心”编译代码。这会导致问题,因为我的知识有限,必须编译 ASP.net MVC。
有人对如何实现这一点有任何建议吗?
谢谢
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-2