031.NET5_ActionFilter的自定义和执行特点

AOP:可以在不修改之前的代码为基础,可以动态的添加新功能;

AuthorizationFilter 鉴权授权

ResourceFilter 资源过滤

ExceptionFilter 异常

ActionFilter 方法

ResultFilter 结果

1. ActionFilter 的特点

自定义一个CustomActionFilterAttribute特性。继承Attribute,并实现方法,标记在Action上。

请求标记有CustomActionFilterAttribute的Action:执行顺序为

a、先控制器的构造函数

b、执行CustomActionFilterAttribute内的OnActionExecuting方法

c、执行Action

d、执行CustomActionFilterAttribute内的OnActionExecuted方法

 

posted on 2021-03-03 22:56  L秦岭  阅读(125)  评论(0编辑  收藏  举报

导航