I use Membership.CreateUser to create users for my web application on demand. But is there a way to “test” the value of MembershipCreateStatus for the user without actually writing the user to the membership database?
I know that I can do something like the following:
MembershipCreateStatus MCS;
var UN = "user@test.com";
var PW = "password";
var SQ = "What is the answer to this security question?";
var SA = "Security answer";
MembershipUser NU = Membership.CreateUser (UN, PW, SQ, SA, true, out MCS);
and then test if MCS is equal to MembershipCreateStatus.Success, MembershipCreateStatus.DuplicateUserName, etc.
But this actually ends up creating the user if MCS is equal to MembershipCreateStatus.Success. Is there a way to test the value of MCS for the combination of UN, PW, etc., without actually creating the user?
Thanks in advance for your help.
First of all, I would suggest that since you are presumably doing this on a development machine, that you should configure your web.config to point at a development database… Thus, who cares what you dump in there!?
However, if you really don’t want to change that… Then you can always go directly to the database to clean up after yourself.