且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Asp.Net Core 2.1 - 根据请求中的内容进行授权

更新时间:2023-02-14 15:30:24

对于将您自己的授权逻辑与 IAuthorizationFilter 一起使用,您不应与 AuthorizeAttribute 一起使用,它会检查使用默认身份验证架构进行身份验证.

For using your own authorize logic with IAuthorizationFilter, you should not use with AuthorizeAttribute which will check the Authentication with default authentication schema.

尝试将 AuthorizeAttribute 更改为 Attribute.

[AttributeUsage(AttributeTargets.Class)]
public class KeyAuthorizeAttribute : Attribute, IAuthorizationFilter
{