The bug During User Creation in ccs1.1 For asp. net2.0 of Baoyu.

Source: Internet
Author: User

Problem: when creating a user, when the user name already exists, the returned error message is "an error occurred when registering a new user .". It is strange that there is an enumeration value "DuplicateUserName" in the returned status of the user to be created. Why does it prompt "An error occurred when registering a new user ." What about it?
After reading the source code (\ src \ Controls \ User \ CreateUser. cs), after calling the User Creation logic (CreateUserStatus createUserStatus = Users. create (user, true);), only one judgment is made: createUserStatus = CreateUserStatus. created, status = System. web. security. membershipCreateStatus. success; for example, the initial value of status is System. web. security. membershipCreateStatus. providerError. In this way, after the user name is repeated, the status is still System. web. security. membershipCreateStatus. providerError. An error occurred.
Modify the code:

Try
{
CreateUserStatus createUserStatus = Users. Create (user, true );
Switch (createUserStatus)
{
Case CreateUserStatus. Created:
Status = System. Web. Security. MembershipCreateStatus. Success;
Break;
Case CreateUserStatus. DuplicateUsername:
Status = System. Web. Security. MembershipCreateStatus. DuplicateUserName;
Break;
Case CreateUserStatus. DuplicateEmailAddress:
Status = System. Web. Security. MembershipCreateStatus. DuplicateEmail;
Break;
Case CreateUserStatus. DuplicateNickname:
// The nickname already exists.
PlaceHolderNicknameValidator. ErrorMessage = CommunityServer. Components. ResourceManager. GetString ("CreateNewAccount_CreateUserStatus_DuplicateNickname ");
PlaceHolderNicknameValidator. IsValid = false;
Return;
Default:
Status = System. Web. Security. MembershipCreateStatus. ProviderError;
Break;
}

}
Catch (System. Web. Security. MembershipCreateUserException exception)
{
Status = exception. StatusCode;
}

After modification, when the user name is repeated, the error message is "sorry, your account has been registered .".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.