Accessing Username in C# server code

I am looking to access the username of the authenticated user in a OnXxxxsRead() partial method, but this.User.Name is null… Where should I look?

Thanks

I have read https://www.radzen.com/documentation/security/ and found this:

var userName = this.HttpContext.User.FindFirst(ClaimTypes.Name).Value;

but this does not work in my code because this.HttpContext.User.FindFirst(ClaimTypes.Name) returns a null…

Hi @semafox,

Could you please try decorating your controller with [Authorize(AuthenticationSchemes="Bearer")] e.g.

 [Authorize(AuthenticationSchemes="Bearer")]
public partial class OrdersController 
{
}  

This seems to be required for ASP.NET Core 2.0 applications (wasn’t required before).

Best regards,
Atanas

Thank you, this worked.