using System.Web.Mvc; public class AppAuthorizeAttribute : AuthorizeAttribute { private string _controllerTypeName = string.Empty; public override void OnAuthorization(AuthorizationContext filterContext) { _controllerTypeName = filterContext.Controller.GetType().FullName; // The following line calls the AuthorizeCore method, below. base.OnAuthorization(filterContext); } /// <returns>True if the user is authorized; false otherwise.</returns> protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext) { var userLoginName = httpContext.User.Identity.Name; // TODO: write specialized authorization code here based on _controllerTypeName and userLoginName return base.AuthorizeCore(httpContext); } }
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.