MVC中施用AuthorizeAttribute做身份验证操作怎么解决

2024-11-22 21:14:29
推荐回答(1个)
回答1:

代码顺序为:OnAuthorization-->AuthorizeCore-->HandleUnauthorizedRequest

如果AuthorizeCore返回false时,才会走HandleUnauthorizedRequest 方法,并且Request.StausCode会返回401,401错误又对应了Web.config中




所有,AuthorizeCore==false 时,会跳转到 web.config 中定义的 loginUrl="~/"