Badmiral Badmiral - 2 months ago 4x
C# Question

Razor Token ResetPassword Not working

I have an MVC3 Razor web site. I am following the tutorial here:

I have been able to generate a token and send the email successfully

Then the email has me going to a resetpassword view at a link like this:


Now, here is my HttpGet method

public ActionResult resetpassword()
ResetPasswordModel model = new ResetPasswordModel()
Password = String.Empty,
ConfirmPassword = String.Empty,
Token = String.Empty
return View(model);

All it does is pass in an instance of the model

My view for resetpassword.cshtml

@model RazorARPP.Models.ResetPasswordModel
var token = Request["token"];
Model.Token = token;

<form action="" method="post" enctype="multipart/form-data" id="MyForm">
<legend>Reset Password</legend>
@Html.HiddenFor(m => m.Token)
@Html.LabelFor(m => m.Password)
@Html.PasswordFor(m => m.Password)


@Html.LabelFor(m => m.ConfirmPassword)
@Html.PasswordFor(m => m.ConfirmPassword)

<input type="submit"/>


Now My HttpPost method

public ActionResult resetpassword(ResetPasswordModel model)
if (model.Password == model.ConfirmPassword)
WebSecurity.ResetPassword(model.Token, model.Password);
return RedirectToAction("Login");

It executes fine but the resetpassword isn't working. I made sure that that line is running in the debugger. Any suggestions as to what I am doing wrong? Thanks


How are you generating the reset token? Are you using the correct username?


Do a test where you generate a token and immediately pass it to WebSecurity.ResetPassword. I'm guessing resetpassword is not getting the values you are expecting