我覆盖了执行自定义授权的类
[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); } } }
<customErrors defaultRedirect="/Shared/Error" mode="On"> <error statusCode="403" redirect="/Shared/UnAuthorize" /> </customErrors>