猿问

请问一下在asp.net core 如何重写AuthorizeAttribute

public class MyAuthorizeAttribute : AuthorizeAttribute
    {        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {            //return base.AuthorizeCore(httpContext);
            return DateTime.Now.Minute % 2 == 0
        }        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            filterContext.HttpContext.Response.Redirect("/Customer/Login");            //base.HandleUnauthorizedRequest(filterContext);        }
    }

用asp.net mvc的方法好象不行啊。指点一下呗


慕容708150
浏览 2862回答 0
0回答

海绵宝宝撒

参考 Custom policy-based authorization
随时随地看视频慕课网APP
我要回答