You are redefining the wrong method, Steve. You want to cancel the cancellation ChangingPassword.
Try the following:
protected void ChangePassword1_ChangingPassword(object sender, LoginCancelEventArgs e)
{
bool passwordHasBeenPreviouslyUsed = true;
if (passwordHasBeenPreviouslyUsed)
{
e.Cancel = true;
return;
}
}
, Q/A, 1. , .
.
(1) - , , ? , , , . .; -)
:
ChangePassword.aspx
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Diagnostics"%>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ChangePassword1_ChangingPassword(object sender, LoginCancelEventArgs e)
{
Debugger.Break();
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ChangePassword ID="ChangePassword1" runat="server" OnChangingPassword="ChangePassword1_ChangingPassword">
</asp:ChangePassword>
</div>
</form>
</body>
</html>
:
, :
public void SetupPasswordActionHook()
{
Membership.ValidatingPassword += Membership_ValidatingPassword;
}
void Membership_ValidatingPassword(object sender, ValidatePasswordEventArgs e)
{
bool isNewUser = e.IsNewUser;
string password = e.Password;
string username = e.UserName;
e.Cancel = true;
e.FailureInformation = new Exception("This is why I failed your password");
}