I have a PasswordRecovery control in my site.
I have my own customized class implementing MembershipProvider.
One of the methods is GetPassword, with username, answer as parameters.
it is activated when the user enters an answer for the question, and the method should check if the answer is correct.
as I understand, if the answer is incorrect, I should throw a MembershipPasswordException.
throw new MembershipPasswordException("MyMessage");
when I go through it on debug mode, VS(2005...) gives me the following Runtime Error
MembershipPasswordException was unhandled by user code
but in the client side it seems like everything is working according to the plan, the user gets an error message saying the answer could not be verified.
So why do I get this error? is it ok anyway?
what am I doing wrong?
thanks
EDIT, this is the problematic code:
conn = GetConnection();
command = new SqlCommand("CustomMemProvider_GetPassword", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("ApplicationID", ApplicationID));
command.Parameters.Add(new SqlParameter("UserName", username));
command.Parameters.Add(new SqlParameter("Answer", Encrypt(answer)));
SqlParameter pPassword = new SqlParameter("@Password", SqlDbType.NVarChar, 256);
pPa开发者_如何学Gossword.Direction = ParameterDirection.Output;
SqlParameter pStatusMessage = new SqlParameter("@StatusMessage", SqlDbType.NVarChar, 256);
pStatusMessage.Direction = ParameterDirection.Output;
command.Parameters.Add(pPassword);
command.Parameters.Add(pStatusMessage);
command.ExecuteNonQuery();
string passToDecrypt = Parse.ObjectToString(pPassword.Value);
if (passToDecrypt == String.Empty)
throw new MembershipPasswordException(Parse.ObjectToString(pStatusMessage.Value));
else
password = Decrypt(Parse.ObjectToString(passToDecrypt));
精彩评论