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); } }