Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Authorize(Roles = "CanDeleteTags")]
- public void Delete(string tagName)
- {
- // ...
- }
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
- public class AuthorizeAttribute : System.Web.Mvc.AuthorizeAttribute
- {
- protected override void HandleUnauthorizedRequest(System.Web.Mvc.AuthorizationContext filterContext)
- {
- if (filterContext.HttpContext.Request.IsAuthenticated)
- {
- filterContext.Result = new System.Web.Mvc.HttpStatusCodeResult(403);
- }
- else
- {
- base.HandleUnauthorizedRequest(filterContext);
- }
- }
- }
- // User was redirected here because of authorization section
- if (User.Identity != null && User.Identity.IsAuthenticated)
- Response.Redirect("Unauthorized.aspx");
Add Comment
Please, Sign In to add comment