MembershipCreateUserException MembershipCreateUserException MembershipCreateUserException MembershipCreateUserException Constructors

Определение

Перегрузки

MembershipCreateUserException() MembershipCreateUserException() MembershipCreateUserException()

Инициализирует новый экземпляр класса MembershipCreateUserException.Initializes a new instance of the MembershipCreateUserException class.

MembershipCreateUserException(String) MembershipCreateUserException(String) MembershipCreateUserException(String) MembershipCreateUserException(String)

Выполняет инициализацию нового экземпляра класса MembershipCreateUserException и задает свойству Message значение предоставленного параметра message.Initializes a new instance of the MembershipCreateUserException class and sets the Message property to the supplied message parameter value

MembershipCreateUserException(MembershipCreateStatus) MembershipCreateUserException(MembershipCreateStatus) MembershipCreateUserException(MembershipCreateStatus) MembershipCreateUserException(MembershipCreateStatus)

Инициализирует новый экземпляр класса MembershipCreateUserException заданным значением StatusCode.Initializes a new instance of the MembershipCreateUserException class with the specified StatusCode value.

MembershipCreateUserException(SerializationInfo, StreamingContext) MembershipCreateUserException(SerializationInfo, StreamingContext) MembershipCreateUserException(SerializationInfo, StreamingContext) MembershipCreateUserException(SerializationInfo, StreamingContext)

Инициализирует новый экземпляр класса MembershipCreateUserException с указанными сведениями о сериализации и контекстом.Initializes a new instance of the MembershipCreateUserException class with the supplied serialization information and context.

MembershipCreateUserException(String, Exception) MembershipCreateUserException(String, Exception) MembershipCreateUserException(String, Exception) MembershipCreateUserException(String, Exception)

Инициализирует новый экземпляр класса MembershipCreateUserException, а также задает в свойстве Message предоставленное message и в свойстве InnerException предоставленное innerException.Initializes a new instance of the MembershipCreateUserException class and sets the Message property to the supplied message and the InnerException property to the supplied innerException.

MembershipCreateUserException() MembershipCreateUserException() MembershipCreateUserException()

Инициализирует новый экземпляр класса MembershipCreateUserException.Initializes a new instance of the MembershipCreateUserException class.

public:
 MembershipCreateUserException();
public MembershipCreateUserException ();
Public Sub New ()

Примеры

В следующем примере кода вызывается Membership.CreateUser метод для создания нового пользователя членства.The following code example calls the Membership.CreateUser method to create a new membership user. Если не удается создать пользователя, MembershipCreateUserException возникает исключение.If the user creation fails, a MembershipCreateUserException is thrown.

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;
}
Public Function MyCreateUser(username As String, password As String, email As String, _
                             question As String, answer As String) As MembershipUser

  Dim status As MembershipCreateStatus

  Dim u As MembershipUser = Membership.CreateUser(username, password, email, question, _
                                                  answer, True, status)
  If u Is Nothing Then
    Throw New MembershipCreateUserException()
  End If

  Return u
End Function

Комментарии

Экземпляр MembershipCreateUserException класса вызывается Membership.CreateUser метод, если пользователь не создан.An instance of the MembershipCreateUserException class is thrown by the Membership.CreateUser method when the user is not created.

Дополнительно

MembershipCreateUserException(String) MembershipCreateUserException(String) MembershipCreateUserException(String) MembershipCreateUserException(String)

Выполняет инициализацию нового экземпляра класса MembershipCreateUserException и задает свойству Message значение предоставленного параметра message.Initializes a new instance of the MembershipCreateUserException class and sets the Message property to the supplied message parameter value

public:
 MembershipCreateUserException(System::String ^ message);
public MembershipCreateUserException (string message);
new System.Web.Security.MembershipCreateUserException : string -> System.Web.Security.MembershipCreateUserException
Public Sub New (message As String)

Параметры

message
String String String String

Описание причины исключения.A description of the reason for the exception.

Примеры

В следующем примере кода вызывается Membership.CreateUser метод для создания нового пользователя членства.The following code example calls the Membership.CreateUser method to create a new membership user. Если не удается создать пользователя, MembershipCreateUserException возникает исключение с сообщением, основываясь на StatusCode возвращаемые CreateUser метод.If the user creation fails, a MembershipCreateUserException is thrown with a message based on the StatusCode returned by the CreateUser method.

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.";
   }
}
Public Function MyCreateUser(username As String, password As String, email As String, _
                             question As String, answer As String) As MembershipUser

  Dim status As MembershipCreateStatus

  Dim u As MembershipUser = Membership.CreateUser(username, password, email, question, _
                                                  answer, True, status)
  If u Is Nothing Then
    Throw New MembershipCreateUserException(GetErrorMessage(status))
  End If

  Return u
End Function


Public Function GetErrorMessage(status As MembershipCreateStatus) As String

   Select Case 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."

      Case Else
        Return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator."
   End Select
End Function

Комментарии

MembershipCreateUserException Класса вызывается Membership.CreateUser метод, если пользователь не создан.The MembershipCreateUserException class is thrown by the Membership.CreateUser method when the user is not created.

Можно использовать message параметра Message свойство исключения для значимое описание причины исключения.You can use the message parameter to set the Message property of the exception to a meaningful description of the reason for the exception.

Дополнительно

MembershipCreateUserException(MembershipCreateStatus) MembershipCreateUserException(MembershipCreateStatus) MembershipCreateUserException(MembershipCreateStatus) MembershipCreateUserException(MembershipCreateStatus)

Инициализирует новый экземпляр класса MembershipCreateUserException заданным значением StatusCode.Initializes a new instance of the MembershipCreateUserException class with the specified StatusCode value.

public:
 MembershipCreateUserException(System::Web::Security::MembershipCreateStatus statusCode);
public MembershipCreateUserException (System.Web.Security.MembershipCreateStatus statusCode);
new System.Web.Security.MembershipCreateUserException : System.Web.Security.MembershipCreateStatus -> System.Web.Security.MembershipCreateUserException
Public Sub New (statusCode As MembershipCreateStatus)

Параметры

statusCode
MembershipCreateStatus MembershipCreateStatus MembershipCreateStatus MembershipCreateStatus

Значение перечисления MembershipCreateStatus, которое описывает причину исключения.A MembershipCreateStatus enumeration value that describes the reason for the exception.

Примеры

В следующем примере кода вызывается CreateUser метод для создания нового пользователя членства.The following code example calls the CreateUser method to create a new membership user. Если не удается создать пользователя, MembershipCreateUserException возникает исключение с StatusCode возвращаемые CreateUser метод.If the user creation fails, a MembershipCreateUserException is thrown with the StatusCode returned by the CreateUser method.

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;
}
Public Function MyCreateUser(username As String, password As String, email As String, _
                             question As String, answer As String) As MembershipUser

  Dim status As MembershipCreateStatus

  Dim u As MembershipUser = Membership.CreateUser(username, password, email, question, _
                                                  answer, True, status)
  If u Is Nothing Then
    Throw New MembershipCreateUserException(status)
  End If

  Return u
End Function

Комментарии

MembershipCreateUserException Класса вызывается Membership.CreateUser метод, если пользователь не создан.The MembershipCreateUserException class is thrown by the Membership.CreateUser method when the user is not created.

statusCode Параметр позволяет указать, почему MembershipCreateUserException было выдано.The statusCode parameter enables you to indicate why the MembershipCreateUserException was thrown. statusCode Значение параметра предоставляется командлетом StatusCode свойство.The statusCode parameter value is exposed by the StatusCode property.

Дополнительно

MembershipCreateUserException(SerializationInfo, StreamingContext) MembershipCreateUserException(SerializationInfo, StreamingContext) MembershipCreateUserException(SerializationInfo, StreamingContext) MembershipCreateUserException(SerializationInfo, StreamingContext)

Инициализирует новый экземпляр класса MembershipCreateUserException с указанными сведениями о сериализации и контекстом.Initializes a new instance of the MembershipCreateUserException class with the supplied serialization information and context.

protected:
 MembershipCreateUserException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected MembershipCreateUserException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Web.Security.MembershipCreateUserException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Web.Security.MembershipCreateUserException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Параметры

info
SerializationInfo SerializationInfo SerializationInfo SerializationInfo

Объект SerializationInfo, хранящий сериализованные данные объекта, относящиеся к выдаваемому исключению.The SerializationInfo that holds the serialized object data about the exception being thrown.

context
StreamingContext StreamingContext StreamingContext StreamingContext

Объект StreamingContext, содержащий контекстные сведения об источнике или назначении.The StreamingContext that contains contextual information about the source or destination.

Примеры

В следующем примере кода показана реализация MembershipCreateUserException класса, который вызывает защищенный конструктор базового класса с указанными сведениями о сериализации и контекстом.The following code example shows an implementation of the MembershipCreateUserException class that calls the protected constructor of the base class with the supplied serialization information and context.

using System.Web.Security;
using System.Runtime.Serialization;

public sealed class MyCreateUserException : MembershipCreateUserException
{
  public MyCreateUserException(SerializationInfo info, StreamingContext context) : base(info, context)
  {
  }
}
Imports System.Web.Security
Imports System.Runtime.Serialization

Public NotInheritable Class MyCreateUserException
  Inherits MembershipCreateUserException

  Public Sub New (info As SerializationInfo, context As StreamingContext)
    MyBase.New(info, context)
  End Sub
End Class

Комментарии

Данный конструктор вызывается в процессе десериализации для воссоздания объекта исключения, переданного в потоке.This constructor is called during deserialization to reconstitute the exception object transmitted over a stream. Дополнительные сведения см. в разделе сериализация XML и SOAP.For more information, see XML and SOAP Serialization.

Дополнительно

MembershipCreateUserException(String, Exception) MembershipCreateUserException(String, Exception) MembershipCreateUserException(String, Exception) MembershipCreateUserException(String, Exception)

Инициализирует новый экземпляр класса MembershipCreateUserException, а также задает в свойстве Message предоставленное message и в свойстве InnerException предоставленное innerException.Initializes a new instance of the MembershipCreateUserException class and sets the Message property to the supplied message and the InnerException property to the supplied innerException.

public:
 MembershipCreateUserException(System::String ^ message, Exception ^ innerException);
public MembershipCreateUserException (string message, Exception innerException);
new System.Web.Security.MembershipCreateUserException : string * Exception -> System.Web.Security.MembershipCreateUserException
Public Sub New (message As String, innerException As Exception)

Параметры

message
String String String String

Описание причины исключения.A description of the reason for the exception.

innerException
Exception Exception Exception Exception

Исключение, вызвавшее MembershipCreateUserException.The exception that caused the MembershipCreateUserException.

Примеры

В следующем примере кода вызывается CreateUser метод для создания нового пользователя членства.The following code example calls the CreateUser method to create a new membership user. Если не удается создать пользователя, MembershipCreateUserException возникает исключение.If the user creation fails, a MembershipCreateUserException is thrown. Если исключение не MembershipCreateUserException, порожденное исключение передается в качестве InnerException из MembershipCreateUserException , возникает исключение.If the exception is not a MembershipCreateUserException, the caught exception is supplied as the InnerException of the MembershipCreateUserException that is thrown.

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;
}
Public Function MyCreateUser(username As String, password As String, email As String) As MembershipUser

  Dim u As MembershipUser = Nothing

  Try
    u = Membership.CreateUser(username, password, email)
  Catch e As MembershipCreateUserException
    Throw e
  Catch e As Exception  
    Throw New MembershipCreateUserException("An exception occurred creating the user.", e)
  End Try

  Return u
End Function

Комментарии

Экземпляр MembershipCreateUserException класса вызывается Membership.CreateUser метод, если пользователь не создан.An instance of the MembershipCreateUserException class is thrown by the Membership.CreateUser method when the user is not created.

Можно использовать эту перегрузку MembershipCreateUserException конструктор, чтобы предоставить сведения, касающиеся перехваченное исключение, произошедшее при создании пользователя.You can use this overload of the MembershipCreateUserException constructor to supply information regarding a caught exception that occurred while the user was being created.

Дополнительно

Применяется к