0
使用MVC Core Identity时,我想知道是否可以从Request.HttpContext.User.Identity
获取更多信息?从Request.HttpContext.User.Identity获取更多
目前,当我看到可用的时候,它给我的回复是Name
,AuthenticationType
和IsAuthenticated
。
我想要做的例子也是获得电子邮件地址。
使用MVC Core Identity时,我想知道是否可以从Request.HttpContext.User.Identity
获取更多信息?从Request.HttpContext.User.Identity获取更多
目前,当我看到可用的时候,它给我的回复是Name
,AuthenticationType
和IsAuthenticated
。
我想要做的例子也是获得电子邮件地址。
//Get User Manager From Owin Context
var userManager = HttpContext.GetOwinContext().GetUserManager<UserManager>();
var user = userManager.FindById(Convert.ToInt32(User.Identity.GetUserId()));
使用上面的代码,它将返回完整的用户对象。我相信解决你的问题?
没错,但我的理解是,如果你只是使用声明,你可以避免所有的处理。 – Bojan
阅读['ClaimsPrincipal'](https://msdn.microsoft.com/en-us/library/system.security.claims.claimsprincipal(v = vs.110).aspx)和相关类。 – Nkosi