Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Web API controller: How to get the signed in user
Fares Ayyad
Dec 11 2017 2:11 PM
130
Reply
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;
//private readonly UserManager _userManager;
//private readonly SignInManager _signInManager;
//private readonly UserManager _manager;
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.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
How to bind dropdownlist when updating data from to db in as
listboxfor in mvc