.NET MemberShip Update Problem
I am having problems updating the MembershipUser.IsApproved field. I have the following code in the POST view of my content page.
MembershipUser membershipUser = Membership.GetUser( id );
if (approved)
membershipUser.IsApproved = true;
else
membershipUser.IsApproved = false;
if (!lockedOut)
membershipUser.UnlockUser();
Membership.UpdateUser( membershipUser );
approved and lockedOut are passed in as parameters to the POST view.
If I set a breakpoint and follow the code through, when approved = true, it follows the correct path and sets membershipUser.IsApproved to true. However, when I look at the IsApproved parameter in membershipUser that is being passed to Membership.UpdateUser, it is still set to false, which is the value it had when the content page was first displayed.
I am obviously doing something wrong, but I can'开发者_如何学运维t see what it is. Can anybody throw any light on it?
It would appear that
membershipUser.UnlockUser();
also sets
membershipUser.IsApproved = false;
Therefore, I need to unlock the User before I set
IsApproved .
精彩评论