I need to access Current User's claims in Middleware before request goes any Controllers.
On login I have set claims like this.
new Claim(ClaimTypes.NameIdentifier, user.ID.ToString());
//...
public async Task InvokeAsync(HttpContext httpContext)
{
var claim = httpContext.User.FindFirst(ClaimTypes.NameIdentifier);
}
It returns null.
I know that we can access this using ControllerBase.User property in Controllers (which I am able to get), But I need to access it in Middleware.
Is there any way to achieve this?
Am I doing something wrong?