ASP.net - 简单列出所有用户

时间:2010-10-12 12:44:52

标签: c# asp.net asp.net-profiles

给定一个配置文件字段,我按以下方式存储每个用户:

Context.Profile.SetPropertyValue("IsSubscribed", isSubscribed.Checked);
Context.Profile.Save();

我如何在其他网页上抓取isSubscribed = true的所有用户电子邮件地址?

1 个答案:

答案 0 :(得分:1)

        List<String> subscribedEmails = new List<String>();

        ProfileInfoCollection profiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All);

        foreach (ProfileInfo profileInfo in profiles)
        {
            ProfileBase profile = ProfileBase.Create(profileInfo.UserName);
            if ((bool)profile.GetPropertyValue("IsSubscribed"))
            {
                subscribedEmails.Add((string)profile.GetPropertyValue("Email"));
            }
        }

编辑:要从会员系统获取用户的电子邮件地址,请使用:

subscribedEmails.Add(Membership.GetUser(profileInfo.UserName).Email);