给定一个配置文件字段,我按以下方式存储每个用户:
Context.Profile.SetPropertyValue("IsSubscribed", isSubscribed.Checked);
Context.Profile.Save();
我如何在其他网页上抓取isSubscribed = true
的所有用户电子邮件地址?
答案 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);