获取会员用户和电子邮件

时间:2016-08-03 18:06:22

标签: asp.net-mvc asp.net-membership

我发现很难理解MembershipUserCollection类的结构。例如,我将All Users作为MembershipUserCollection,但我无法访问MembershipUser以获取用户的电子邮件。以下是我目前所做的一个示例:

 MembershipUserCollection AllUsers = Membership.GetAllUsers();
 foreach (var user in AllUsers)
   {
     var userName = user.ToString();
     // Is there a better way to get the email within loop without having to call the GetUser method??
     var email = Membership.GetUser(user).Email 
   }

enter image description here

1 个答案:

答案 0 :(得分:1)

尝试使用

https://accounts.google.com/o/oauth2/auth?client_id=123456.apps.googleusercontent.com&redirect_uri=https://www.google.com&access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fanalytics+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fanalytics.edit+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fspreadsheets.google.com%2Ffeeds+https%3A%2F%2Fdocs.google.com%2Ffeeds+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.file+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&response_type=code&approval_prompt=force