ValidatePasswordEventArgs.FailureInformation Property
.NET Framework 3.0
Gets or sets an exception that describes the reason for the password-validation failure.
Namespace: System.Web.Security
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
'Declaration Public Property FailureInformation As Exception 'Usage Dim instance As ValidatePasswordEventArgs Dim value As Exception value = instance.FailureInformation instance.FailureInformation = value
/** @property */ public Exception get_FailureInformation () /** @property */ public void set_FailureInformation (Exception value)
public function get FailureInformation () : Exception public function set FailureInformation (value : Exception)
Not applicable.
Property Value
An Exception that describes the reason for the password-validation failure.The FailureInformation property is used when the current CreateUser, ChangePassword, or ResetPassword action has been canceled by setting the Cancel property to true.
The FailureInformation property is set to an exception that describes the reason for the password-validation failure. The calling method will throw the exception that the FailureInformation property is set to. If the FailureInformation property is a null reference (Nothing in Visual Basic), the caller will throw a generic password-validation failure exception.
The following code example shows a ValidatingPassword event that validates the format of the password for the user and cancels the action if the password does not match the required format.
Public Sub Page_Load() AddHandler Membership.ValidatingPassword, _ New MembershipValidatePasswordEventHandler(AddressOf OnValidatePassword) End Sub Public Sub OnValidatePassword(sender As Object, _ args As ValidatePasswordEventArgs) Dim r As System.Text.RegularExpressions.Regex = _ New System.Text.RegularExpressions.Regex("(?=.{6,})(?=(.*\d){1,})(?=(.*\W){1,})") If Not r.IsMatch(args.Password) Then args.FailureInformation = _ New HttpException("Password must be at least 6 characters long and " & _ "contain at least one number and one special character.") args.Cancel = True End If End Sub
Community Additions
ADD
Show: