我在我的项目上有重置密码功能。我正在使用令牌向用户发送链接。点击链接后,我需要进入我的HomeController
并激活ResetPassword
方法。我的问题是,我不确定在哪里放置ResetPassword
部分视图(这是模式),无论我放在哪里,它都会在我打开登录页面时引入。我应该在哪里放置我的部分视图
考虑用户电子邮件此链接:
http://...myurlaction=resetpassword&userid=5&[email protected]&token=1234564
当他们点击它,我需要去这个方法:
首先得获得方法:
[HttpGet]
[Route("resetpassword")]
[AllowAnonymous]
public ActionResult ResetPassword(ResetPasswordRequest resetPasswordRequest)
{
//check if Token is valid show the view
return PartialView();
}
发帖后,去POST
方法:
[HttpPost]
[Route("resetpassword")]
public ActionResult ResetPassword(ResetPasswordView resetPasswordView)
{
return PartialView();
}
,这是局部视图:
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">x</span>
@using (Html.BeginForm("resetpassword", "Home", FormMethod.Post))
{
<h5>Reset Your Loan Center Password</h5>
<table>
<tr><td>Email Address</td><td><input type="email" name="Email" placeholder="[email protected]"></td></tr>
<tr><td>Password</td><td><input type="Password" name="Password" placeholder="Create Password"></td></tr>
<tr><td>Confirm Password</td><td><input type="Password" name="ConfirmPassword" placeholder="Re-enter Password"></td></tr>
<tr><td colspan="2"><input type="submit" value="Reset Password"></td></tr>
<tr>
<td class="errMessage" colspan="2">
@Html.ValidationSummary(true)
</td>
</tr>
</table>
}
</div>
我的问题是,我不知道我必须有@Html.Partial("Login")
,因为无论我有它显示重置密码查看就算我不不需要显示它。
您POST方法也需要'[使用AllowAnonymous]' - 用户尚未授权(他们不应该有相同的签名) –
@Stephen Muecke,事情是去后,我张贴在视图中输入值但不会去获取。 – Alma