當前位置: 首頁>>代碼示例>>C#>>正文


C# MembershipCreateUserException構造函數代碼示例

本文整理匯總了C#中System.Web.Security.MembershipCreateUserException.MembershipCreateUserException構造函數的典型用法代碼示例。如果您正苦於以下問題:C# MembershipCreateUserException構造函數的具體用法?C# MembershipCreateUserException怎麽用?C# MembershipCreateUserException使用的例子?那麽, 這裏精選的構造函數代碼示例或許可以為您提供幫助。


在下文中一共展示了MembershipCreateUserException構造函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MyCreateUser

public MembershipUser MyCreateUser(string username, string password, string email,
                                   string question, string answer)
{
  MembershipCreateStatus status;

  MembershipUser u = Membership.CreateUser(username, password, email, question, 
                                           answer, true, out status);
  if (u == null)
  {
    throw new MembershipCreateUserException();
  }

  return u;
}
開發者ID:.NET開發者,項目名稱:System.Web.Security,代碼行數:14,代碼來源:MembershipCreateUserException

示例2: MyCreateUser

public MembershipUser MyCreateUser(string username, string password, string email,
                                   string question, string answer)
{
  MembershipCreateStatus status;

  MembershipUser u = Membership.CreateUser(username, password, email, question, 
                                           answer, true, out status);
  if (u == null)
  {
    throw new MembershipCreateUserException(GetErrorMessage(status));
  }

  return u;
}

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 email address already exists. Please enter a different email address.";

      case MembershipCreateStatus.InvalidPassword:
        return "The password provided is invalid. Please enter a valid password value.";

      case MembershipCreateStatus.InvalidEmail:
        return "The email 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.";
   }
}
開發者ID:.NET開發者,項目名稱:System.Web.Security,代碼行數:50,代碼來源:MembershipCreateUserException

示例3: MyCreateUser

public MembershipUser MyCreateUser(string username, string password, string email,
                                   string question, string answer)
{
  MembershipCreateStatus status;

  MembershipUser u = Membership.CreateUser(username, password, email, question, 
                                           answer, true, out status);

  if (u == null)
  {
    throw new MembershipCreateUserException(status);
  }

  return u;
}
開發者ID:.NET開發者,項目名稱:System.Web.Security,代碼行數:15,代碼來源:MembershipCreateUserException

示例4: MyCreateUserException

//引入命名空間
using System.Web.Security;
using System.Runtime.Serialization;

public sealed class MyCreateUserException : MembershipCreateUserException
{
  public MyCreateUserException(SerializationInfo info, StreamingContext context) : base(info, context)
  {
  }
}
開發者ID:.NET開發者,項目名稱:System.Web.Security,代碼行數:10,代碼來源:MembershipCreateUserException

示例5: MyCreateUser

public MembershipUser MyCreateUser(string username, string password, string email)
{
  MembershipUser u = null;

  try
  {
    u = Membership.CreateUser(username, password, email);
  }
  catch (MembershipCreateUserException e)
  {  
    throw e;
  }
  catch (Exception e)
  {  
    throw new MembershipCreateUserException("An exception occurred creating the user.", e);
  }

  return u;
}
開發者ID:.NET開發者,項目名稱:System.Web.Security,代碼行數:19,代碼來源:MembershipCreateUserException


注:本文中的System.Web.Security.MembershipCreateUserException.MembershipCreateUserException構造函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。