API控制器未正确返回User.Identity声明

时间:2019-06-04 12:35:28

标签: c# .net api .net-core claims

我有一个非常简单的api控制器方法,该方法应返回已登录用户的声明。当我调试应用程序ClaimsIdentity.Claims正确显示声明的数组。

但是当我用招摇或邮递员测试时,我只会得到

Could not get any response
There was an error connecting to http://localhost:59215/api/v1/GetClaims.

API方法:

    [Route("GetClaims")]
    [HttpGet]
    [ProducesResponseType(typeof(IEnumerable<Claim>), StatusCodes.Status200OK)]
    public IEnumerable<Claim> GetClaims()
    {
        var claimsIdentity = User.Identity as ClaimsIdentity;
        return claimsIdentity.Claims;
    }

所有其他API方法都可以正常工作。

0 个答案:

没有答案
相关问题