mvc過(guò)濾器學(xué)習(xí)(1)
mvc 過(guò)濾器結(jié)構(gòu)圖
AuthorizeAttribute
AuthorizeAttribute是IAuthorizationFilter的默認(rèn)實(shí)現(xiàn),添加了Authorize特性的Action將對(duì)用戶(hù)進(jìn)行驗(yàn)證授權(quán),只有通過(guò)了用戶(hù)才可以進(jìn)入這個(gè)Action.
AuthorizeAttribute提供了四種操作方法,打開(kāi).net reflector查看源碼
1.在進(jìn)入Action之前首先執(zhí)行OnAuthorization
public virtual void OnAuthorization(AuthorizationContext filterContext) { if (filterContext == null) { throw new ArgumentNullException("filterContext網(wǎng)友評(píng)論