0

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

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

我将如何在另一个页面上获取所有用户的电子邮件地址isSubscribed = true

4

1 回答 1

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);
于 2010-10-12T15:25:30.480 回答