我想设置和保存使用ASP.NET MVC 3,会员提供商内部的电子邮件的变化,我不知道如何正确地设置和更改会员提供商内部的电子邮件属性。
MSDN似乎暗示MembershipUser.Email属性,因为它“获取或设置电子邮件地址的会员用户,”但我不知道怎么去实现应有的功能。
我试图用这个代码:
// change email
MembershipUser u = Membership.GetUser(User.Identity.Name);
u.Email = email; // Is this working as expected?
u.Save(); // this line doesn't do anything - what should it be?
db.Save(); <-- that is what I would do with ordinary database changes, but I don't know what context to use for Membership Provider changes. . .
编辑:
我想到了:
// change email
MembershipUser u = Membership.GetUser(User.Identity.Name);
u.Email = email;
System.Web.Security.Membership.UpdateUser(u);