This is my code in UserController and it runs well.
private Identifier GetCurrentUser()
{
var identity = HttpContext.User.Identity as ClaimsIdentity;
if (identity != null)
{
var userClaims = identity.Claims;
return new Identifier
{
Id = userClaims.FirstOrDefault(o => o.Type == ClaimTypes.NameIdentifier)?.Value,
Role = userClaims.FirstOrDefault(o => o.Type == ClaimTypes.Role)?.Value,
};
}
return null;
}
However when I change this method from private to public I got this error with swagger.
I do not understand why I get this error. Please tell me the reason and teach me how to fix it. Thank for your attention