Advertisement
HenX

CustomAuthorize

Dec 23rd, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1.   public class CustomAuthorize : AuthorizeAttribute
  2.     {
  3.         protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
  4.         {
  5.             filterContext.Result = new RedirectResult("~/Home/Chyba403");
  6.         }
  7.  
  8.         public override void OnAuthorization(AuthorizationContext filterContext)
  9.         {
  10.             if (this.AuthorizeCore(filterContext.HttpContext))
  11.             {
  12.                 base.OnAuthorization(filterContext);
  13.             }
  14.             else
  15.             {
  16.                 this.HandleUnauthorizedRequest(filterContext);
  17.             }
  18.         }
  19.     }
  20.  
  21.     [CustomAuthorize(Roles = "admin,publisher")]
  22.     public ActionResult EditovatAktualitu(int id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement