//請求授權時執行 public override void OnAuthorization(AuthorizationContext filterContext) { accessible = false; //獲得url請求裡的controller和action string ctrlName = filterContext.RouteData.Values["controller"].ToString(); string actName = filterContext.RouteData.Values["action"].ToString(); if (IdentityHelper.UserId != null) { int userId = (int)IdentityHelper.UserId; accessible = featSrv.Accessible(userId, ctrlName, actName); } base.OnAuthorization(filterContext);//進入AuthorizeCore }