Get ASP.NET Identity Current User In View

后端 未结 4 1575
無奈伤痛
無奈伤痛 2020-12-30 05:01

I use ASP.NET Identity 2.0 and MVC. I need to logged user\'s name,surname,email etc.. in view. How can get it? I can get just @User.Identity but there no my user class\'s pr

4条回答
  •  生来不讨喜
    2020-12-30 06:00

    to get information about the user from the controller you must use

    User.Identity.GetUserId();
    

    or if you want to get information about the user within your class

    HttpContext.Current.User.Identity.GetUserId();
    

提交回复
热议问题