Hello,
I'm trying to figure out how to get the current Identity user information, basically i do the following:
- [Produces("application/json")]
- [Route("api/GetPermissions")]
- public class GetPermissionsController : Controller
- {
-
- private readonly ClaimsPrincipal _caller;
-
-
-
- public GetPermissionsController(ClaimsPrincipal caller)
- {
- _caller = caller;
- }
-
- [HttpGet]
- public IActionResult getPermissions()
- {
- var x= HttpContext.Request.LogonUserIdentity.Name;
- return new JsonResult(_caller.Claims.Select(
- c => new { c.Type, c.Value }));
- }
when i tried to hit the api using POSTMAN, it returned with 500 interval server error.
In my scenario i want to get the username to Angular service.