TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Fares Ayyad
NA
235
74.3k
Web API controller: How to get the signed in user
Dec 11 2017 2:11 PM
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.
Reply
Answers (
1
)
How to bind dropdownlist when updating data from to db in as
listboxfor in mvc