Esempio n. 1
0
 public void OnAuthorization(AuthorizationContext filterContext)
 {
     try
     {
         G9_Service sv = new G9_Service();
         var userType = sv.getLoaiTaiKhoanByUserName(HttpContext.Current.User.Identity.Name);
         bool flag = false;
         var listPer = sv.getListPermissionByRole(userType.MaLoaiTK);
         String textAction = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName + "_" + filterContext.ActionDescriptor.ActionName;
         foreach (var cur in listPer)
         {
             if (textAction == cur.ControllerName)
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
             filterContext.Result = new RedirectResult("../Home/Warning");
     }
     catch
     {
         filterContext.Result = new RedirectResult("../Home/Warning");
     }
 }