Membership create user exeption
-
hi all, Iam trying to create a new user programmatically by using Membership.CreateUser(username As String, password As String). When I try to create a new user by using the code below, I get following errormessage Error 102 Validation (ASP.Net): Attribute values must be enclosed in quotation marks. MembershipCreateUserException: The password-answer supplied is invalid and I do not understand what I am doing wrong. I hope someone can help me with this.
Kareem Elhosseny
-
hi all, Iam trying to create a new user programmatically by using Membership.CreateUser(username As String, password As String). When I try to create a new user by using the code below, I get following errormessage Error 102 Validation (ASP.Net): Attribute values must be enclosed in quotation marks. MembershipCreateUserException: The password-answer supplied is invalid and I do not understand what I am doing wrong. I hope someone can help me with this.
Kareem Elhosseny
Membership.CreateUser(string, string) will returns a MembershipUser object for newly created user. Retrieve a MembershipCreateStatus value from the StatusCode property of the MembershipCreateUserException that indicates why user creation failed. MembershipCreateStatus object will returns the follwing status codes
DuplicateEmail: The e-mail address already exists in the database for the application. DuplicateProviderUserKey: The provider user key already exists in the database for the application. DuplicateUserName: The user name already exists in the database for the application. InvalidAnswer: The password answer is not formatted correctly. InvalidEmail: The e-mail address is not formatted correctly. InvalidPassword: The password is not formatted correctly. InvalidProviderUserKey: The provider user key is of an invalid type or format. InvalidQuestion: The password question is not formatted correctly. InvalidUserName: The user name was not found in the database. ProviderError: The provider returned an error that is not described by other MembershipCreateStatus: enumeration values. Success: The user was successfully created. UserRejected: The user was not created, for a reason defined by the provider
capture the status & based on this status use overloaded CreateUser functionRamana
-
Membership.CreateUser(string, string) will returns a MembershipUser object for newly created user. Retrieve a MembershipCreateStatus value from the StatusCode property of the MembershipCreateUserException that indicates why user creation failed. MembershipCreateStatus object will returns the follwing status codes
DuplicateEmail: The e-mail address already exists in the database for the application. DuplicateProviderUserKey: The provider user key already exists in the database for the application. DuplicateUserName: The user name already exists in the database for the application. InvalidAnswer: The password answer is not formatted correctly. InvalidEmail: The e-mail address is not formatted correctly. InvalidPassword: The password is not formatted correctly. InvalidProviderUserKey: The provider user key is of an invalid type or format. InvalidQuestion: The password question is not formatted correctly. InvalidUserName: The user name was not found in the database. ProviderError: The provider returned an error that is not described by other MembershipCreateStatus: enumeration values. Success: The user was successfully created. UserRejected: The user was not created, for a reason defined by the provider
capture the status & based on this status use overloaded CreateUser functionRamana
-
Membership.CreateUser(string, string) will returns a MembershipUser object for newly created user. Retrieve a MembershipCreateStatus value from the StatusCode property of the MembershipCreateUserException that indicates why user creation failed. MembershipCreateStatus object will returns the follwing status codes
DuplicateEmail: The e-mail address already exists in the database for the application. DuplicateProviderUserKey: The provider user key already exists in the database for the application. DuplicateUserName: The user name already exists in the database for the application. InvalidAnswer: The password answer is not formatted correctly. InvalidEmail: The e-mail address is not formatted correctly. InvalidPassword: The password is not formatted correctly. InvalidProviderUserKey: The provider user key is of an invalid type or format. InvalidQuestion: The password question is not formatted correctly. InvalidUserName: The user name was not found in the database. ProviderError: The provider returned an error that is not described by other MembershipCreateStatus: enumeration values. Success: The user was successfully created. UserRejected: The user was not created, for a reason defined by the provider
capture the status & based on this status use overloaded CreateUser functionRamana
-
here is my exactelly code but it dosnt work the error related to the password format but i dont know it specificelly MembershipUser newuser= Membership.CreateUser("kareem", "P@ssw0rd"); plz answer me Romana
Kareem Elhosseny
see this code
public void CreateUser_OnClick(object sender, EventArgs args) { // Create new user and retrieve create status result. MembershipCreateStatus status; string passwordQuestion = ""; string passwordAnswer = ""; if (Membership.RequiresQuestionAndAnswer) { passwordQuestion = PasswordQuestionTextbox.Text; passwordAnswer = PasswordAnswerTextbox.Text; } try { MembershipUser newUser = Membership.CreateUser(UsernameTextbox.Text, PasswordTextbox.Text,EmailTextbox.Text, passwordQuestion, passwordAnswer, true, out status); if (newUser == null) { Msg.Text = GetErrorMessage(status); } else { Response.Redirect("login.aspx"); } } catch { Msg.Text = "An exception occurred creating the user."; } } public string GetErrorMessage(MembershipCreateStatus status) { switch (status) { case MembershipCreateStatus.DuplicateUserName: return "Username already exists. Please enter a different user name."; case MembershipCreateStatus.DuplicateEmail: return "A username for that e-mail address already exists. Please enter a different e-mail address."; case MembershipCreateStatus.InvalidPassword: return "The password provided is invalid. Please enter a valid password value."; case MembershipCreateStatus.InvalidEmail: return "The e-mail address provided is invalid. Please check the value and try again."; case MembershipCreateStatus.InvalidAnswer: return "The password retrieval answer provided is invalid. Please check the value and try again."; case MembershipCreateStatus.InvalidQuestion: return "The password retrieval question provided is invalid. Please check the value and try again."; case MembershipCreateStatus.InvalidUserName: return "The user name provided is invalid. Please check the value and try again."; case MembershipCreateStatus.ProviderError: return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator."; case MembershipCreateStatus.UserRejected: return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator."; default: return "An unknown error occurred. Please verify your entry an
-
see this code
public void CreateUser_OnClick(object sender, EventArgs args) { // Create new user and retrieve create status result. MembershipCreateStatus status; string passwordQuestion = ""; string passwordAnswer = ""; if (Membership.RequiresQuestionAndAnswer) { passwordQuestion = PasswordQuestionTextbox.Text; passwordAnswer = PasswordAnswerTextbox.Text; } try { MembershipUser newUser = Membership.CreateUser(UsernameTextbox.Text, PasswordTextbox.Text,EmailTextbox.Text, passwordQuestion, passwordAnswer, true, out status); if (newUser == null) { Msg.Text = GetErrorMessage(status); } else { Response.Redirect("login.aspx"); } } catch { Msg.Text = "An exception occurred creating the user."; } } public string GetErrorMessage(MembershipCreateStatus status) { switch (status) { case MembershipCreateStatus.DuplicateUserName: return "Username already exists. Please enter a different user name."; case MembershipCreateStatus.DuplicateEmail: return "A username for that e-mail address already exists. Please enter a different e-mail address."; case MembershipCreateStatus.InvalidPassword: return "The password provided is invalid. Please enter a valid password value."; case MembershipCreateStatus.InvalidEmail: return "The e-mail address provided is invalid. Please check the value and try again."; case MembershipCreateStatus.InvalidAnswer: return "The password retrieval answer provided is invalid. Please check the value and try again."; case MembershipCreateStatus.InvalidQuestion: return "The password retrieval question provided is invalid. Please check the value and try again."; case MembershipCreateStatus.InvalidUserName: return "The user name provided is invalid. Please check the value and try again."; case MembershipCreateStatus.ProviderError: return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator."; case MembershipCreateStatus.UserRejected: return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator."; default: return "An unknown error occurred. Please verify your entry an
really thx alot for your effort but the createuser method have an overload takes two variables username and password only so i did't have to check in if (Membership.RequiresQuestionAndAnswer) { passwordQuestion = PasswordQuestionTextbox.Text; passwordAnswer = PasswordAnswerTextbox.Text; } and when i try your code its give me there is an exeption sothe result write in the msg label "An exception occurred creating the user" i think my problem in the formating of password and the exeption told me that wht can i do ?
Kareem Elhosseny
-
really thx alot for your effort but the createuser method have an overload takes two variables username and password only so i did't have to check in if (Membership.RequiresQuestionAndAnswer) { passwordQuestion = PasswordQuestionTextbox.Text; passwordAnswer = PasswordAnswerTextbox.Text; } and when i try your code its give me there is an exeption sothe result write in the msg label "An exception occurred creating the user" i think my problem in the formating of password and the exeption told me that wht can i do ?
Kareem Elhosseny
Try a different password?