Things to remember when using Membership.UpdateUser(MembershipUser user)
December 17, 2009 5 Comments
You got to love programming it thows you one curve ball efter another (c: thats why i love it so ,..
Her is a good thing to remember,. when updating membership users, Lets say you want to do something like this
user.IsApproved = true; //reactivate user
user.Comment = “mjau”; //change comment
Membership.UpdateUser(user);
this code will run just fine, but the result is not what you would expect
When it executes it will only update user.Comment = “mjau” on the other hand user.IsApproved will never be updated.
To make it work you must call Membership.UpdateUser() everytime you make an update, like this.
user.IsApproved = true; //reactivate user
Membership.UpdateUser(user);
user.Comment = “mjau”; //change comment
Membership.UpdateUser(user);
Well, that is my conclusion after some trail and error runs
happy coding
Edit: Check out Sky Sanders Solution for this problem: http://stackoverflow.com/questions/2721658/membership-updateuser-not-really-updating-the-database/2722173#2722173
Trial and error is not a reliable technique and your information is misleading.
You might get some insight by using reflector.
Thanks for the comments. I’ve taken your input in to advise, but sometimes googling for answers doesn’t result in a solution , so the next best thing is trial and error, which is also meant as a mean to test the code.
No I don’t provide all the code but only a snipped which made the difference in my code.
Your conclusion is incorrect. You have other issues that are not apparent in this post.
See http://stackoverflow.com/questions/2721658/membership-updateuser-not-really-updating-the-database/2722173#2722173
for more information
Hi There,
I don’t care if this blog posting is ‘wrong’, I worked for me. Thanks maanehunden!
Bye for now
Jason.
Nice to hear Jason, glad to have helped (c: