我是
靠谱客的博主
缥缈超短裙,最近开发中收集的这篇文章主要介绍
MVC3 Action执行前或执行后处理的方法,觉得挺不错的,现在分享给大家,希望可以做个参考。
使用以下方法的类需要继承System.Web.Mvc.Controller;
public override voidOnActionExecuted(ActionExecutedContext filterContext)
{ //在Action执行之后执行 输出到输出流中文字:After Action Excutexxx
filterContext.HttpContext.Response.Write(@"<br/>After Action Excute" + "t " + Message);
base.OnActionExecuted(filterContext);
}
public override voidOnActionExecuting(ActionExecutingContext filterContext)
{ //在Action执行前执行
filterContext.HttpContext.Response.Write(@"<br/>Before Action Excute" + "t " + Message);
base.OnActionExecuting(filterContext);
}
public override voidOnResultExecuted(ResultExecutedContext filterContext)
{ //在Result执行之后
filterContext.HttpContext.Response.Write(@"<br/>After ViewResult Excute" + "t " + Message);
base.OnResultExecuted(filterContext);
}
public override voidOnResultExecuting(ResultExecutingContext filterContext)
{ //在Result执行之前
filterContext.HttpContext.Response.Write(@"<br/>Before ViewResult Excute" + "t " +Message);
base.OnResultExecuting(filterContext);
}
发表评论 取消回复