Asp.Net MVC 1.0 Action Filters Tips

1.Action Filters Interface

  • IAuthorizationFilter
  • IActionFilter
  • IResultFilter
  • IExceptionFilter

2.Action Filters Interface Execute Order

(1).IAuthorizationFilter.OnAuthorization(AuthorizationContext filterContext)

(2).IActionFilter.OnActionExecuting(ActionExecutingContext filterContext)

(3).Action Content

(4).IActionFilter.OnActionExecuted(ActionExecutingContext filterContext)

(5).IResultFilter.OnResultExecuting(ResultExecutedContext filterContext)

(6).IResultFilter.OnResultExecuted(ResultExecutedContext filterContext)

(7).IExceptionFilter.OnResultExecuted(ExceptionContext filterContext)

3.Implement a particular type of filter

(1)If you want to implement a particular type of filter, then you need to create a class that inherits from System.Web.Mvc.FilterAttribute class and implements one or more of the IAuthorizationFilter, IActionFilter, IResultFilter, or ExceptionFilter interfaces.

(2)Just inherits from ActionFilterAttribute and overwirte the methods.(By default,The ActionFilterAttribute class implements IActionFilter and IResultFilter interface).

posted @ 2009-11-03 17:21  零零猪  阅读(307)  评论(0编辑  收藏  举报