本文介绍了在保存ASP.NET MVC的默认成员资格提供程序内的电子邮件的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图来设置和使用ASP.NET MVC 3成员资格提供程序中保存电子邮件的变化,我不知道如何正确地设置和成员资格提供程序中更改电子邮件属性。
MSDN似乎暗示MembershipUser.Email属性,因为它,获取或设置电子邮件地址,成员资格用户,但我不知道如何得到这个正常工作。
我试图用这个code:
//改变电子邮件
的MembershipUser U = Membership.GetUser(User.Identity.Name);
u.Email =电子邮件; //这是工作正常?
u.Save(); //这一行不能做任何事情 - 什么应该是什么?
db.Save(); < - 这就是我会做与普通数据库的变化,但我不知道是干什么用上下文成员资格提供程序的变化。 。 。
编辑:
我想通了:
//改变电子邮件
的MembershipUser U = Membership.GetUser(User.Identity.Name);
u.Email =电子邮件;
System.Web.Security.Membership.UpdateUser(U);
解决方案
尝试UpdateUser两个:
VAR用户= Membership.GetUser(ID);
user.Email [email protected];
Membership.UpdateUser(用户);
I am trying to set and save an email change using within the Membership Provider in ASP.NET MVC 3. I do not know how to properly set and change the email property within the Membership Provider.
MSDN seems to suggest the MembershipUser.Email Property as it, "Gets or sets the e-mail address for the membership user," but I do not know how to get this to function properly.
I am attempting to use this code:
// 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. . .
EDIT:
I figured it out:
// change email
MembershipUser u = Membership.GetUser(User.Identity.Name);
u.Email = email;
System.Web.Security.Membership.UpdateUser(u);
解决方案
Try UpdateUser:
var user = Membership.GetUser(id);
user.Email = "[email protected]";
Membership.UpdateUser(user);
这篇关于在保存ASP.NET MVC的默认成员资格提供程序内的电子邮件的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!