当前位置: 首页>>代码示例>>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;未经允许,请勿转载。