ASP.NET Core多种身份验证方案

时间:2020-01-05 08:54:54

标签: asp.net core

我想实现2种身份验证方案,但是我的代码出现错误

分配给AuthSchemes的表达式必须为常量

代码:

[Authorize(AuthenticationSchemes = AuthSchemes )]
[Route("api/[controller]")]
[ApiController]
public class SomeController : ControllerBase
{
        private const string AuthSchemes =
        IdentityConstants.ApplicationScheme + "," +
        JwtBearerDefaults.AuthenticationScheme;

但是我可以这样做

private const string AuthSchemes =
        "Identity.Application" + "," +
        JwtBearerDefaults.AuthenticationScheme;

如何解决第一个实现?

0 个答案:

没有答案