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).