I'm developing an api which is using JwtBearer for authentication.When I'm try to using User.Identity like this;
[HttpGet]
public IActionResult Detail(int id)
{
if(User.Identity.IsAuthenticated)
{
return ...
}
else
{
return ..
}
}
User not contain token/user data and User.Identity.IsAuthenticated always return false. But if i add
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
This get User data but i want unauthenticated user can access too.
How could I do this without an Authorize filter?