[英]AWS Cognitive Hosted UI display signed in username in asp.net core web app
We have implemented AWS Cognitive Hosted UI in my asp.net core web app and it works a treat. 我们已经在我的asp.net核心Web应用程序中实现了AWS Cognitive Hosted UI,并且可以正常工作。 We would now like to display the user information of the signed in user but aren't sure how this can be implemented. 现在,我们想显示已登录用户的用户信息,但是不确定如何实现。 Can someone point us to a working example? 有人可以指出我们一个可行的例子吗?
To access information regarding the signed in user you can use the following: 要访问有关已登录用户的信息,可以使用以下命令:
var username = HttpContext.User.Claims.FirstOrDefault(c => c.Type.Equals("cognito:username")).Value;
var givenname = HttpContext.User.Claims.FirstOrDefault(c => c.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname")).Value;
var surname = HttpContext.User.Claims.FirstOrDefault(c => c.Type.Equals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname")).Value;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.