Nobody on theis issue?
Answer to my own question
The forgot password to work:
1. In the web.config file we would set the RequireQuestionAndAnswer=true
2. In the ForgotPassword action method we have to insert a Try/Catch:
if (!String.IsNullOrEmpty(secretAnswer))
{
try
{
string resetPassword = Membership.Provider.ResetPassword(userName, secretAnswer);
if (Membership.ValidateUser(userName, resetPassword))
{
FormsAuthentication.SetAuthCookie(userName, false);
return RedirectToAction("ChangePassword", new { resetPassword = resetPassword });
}
else
{
TempData["ErrorMessage"] = "Invalid Response";
return View();
}
}
catch (Exception ex)
{
TempData["ErrorMessage"] = ex.Message;
}
}
Last edited by Gabor66; November 7th, 2009 at 03:35 PM..
|