WCF 및 Membership.CreateUser를 사용하여 Silverlight 웹 앱을 사용하여 새 사용자를 만듭니다.사용자를 만들거나 생성에 실패하면 저장시 더 이상 시도 할 때마다 MembershipCreteStatus가 두 번 이상 반환됩니다.
사용자를 성공적으로 만든 다음 다른 사용자를 만들면 "사용자가 성공적으로 생성되었습니다"라는 상태 메시지가 두 번 표시됩니다. 또는 사용자 이름이 이미 있기 때문에 새 사용자를 만들기위한 첫 번째 시도가 실패한 경우 추가 시도는 상태 메시지를 두 번 이상 가져옵니다. 방법
tmsClient.CreateNewUserCompleted += new EventHandler<CreateNewUserCompletedEventArgs>(tmsClient_CreateNewUserCompleted);
tmsClient.CreateNewUserAsync(nu.UserName, nu.Password, nu.Email, nu.SecurityQuestion, nu.SecurityAnswer);
에
내 WCF 서비스 코드
[OperationContract]
public MembershipCreateStatus CreateNewUser(string userName, string password, string email, string securityQuestion, string securityAnswer)
{
MembershipCreateStatus status = new MembershipCreateStatus();
MembershipUser newUser = Membership.CreateUser(userName, password, email, securityQuestion, securityAnswer, true, out status);
return status;
}
내 전화 내 이벤트
void tmsClient_CreateNewUserCompleted(object sender, CreateNewUserCompletedEventArgs e)
{
MembershipCreateStatus status = e.Result;
string result = GetErrorMessage(status);
MessageBox.Show(result);
}
그리고 마지막으로 따라 GetErrorMessage 방법을 완료
public string GetErrorMessage(MembershipCreateStatus status)
{
switch (status)
{
case MembershipCreateStatus.Success:
return "The user was successfully created.";
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 and try again. If the problem persists, please contact your system administrator.";
}
}
왜 이런 일이 발생했는지에 대한 아이디어가 있습니까? 텍사스
닐
위대한 작품입니다. 감사합니다. dmusial – Neill