How to get user id of logged in user in .NET Core 2.0?

后端 未结 5 916
旧时难觅i
旧时难觅i 2021-01-03 04:15

I have created a angular 2 application using .NET Core and MVC. I want to know the login id of user. How to get logged in id of a user in .net core?

This is my first

5条回答
  •  北海茫月
    2021-01-03 04:49

    Assuming you are using ASP.NET Identity, what about (in your controller action):

    User.Identity.GetUserId();
    

    or (if you use a custom key type)

    User.Identity.GetUserId();
    

提交回复
热议问题