I have this code:
MembershipUser user = Membership.GetUser(model.UserName);
if (user != null)
user.IsApproved = false;
The call to user.IsApproved above does set the IsApproved flag to false but when I subsequently do:
MembershipUser user = Membership.GetUser(model.UserName);
and check the IsApproved flag the value is true!
What’s wrong?
You need to save the change, otherwise you’re just setting it to false for the current object. You can use
Membership.UpdateUser(http://msdn.microsoft.com/en-us/library/system.web.security.membership.updateuser.aspx).