我有一個重置密碼方法,我將其發佈到MVC中。當我點擊提交按鈕和頁面發佈的URL會是這樣的:http://localhost:11580/resetpassword 所以它會帶來的URL中的操作方法的名稱,這就是爲什麼頁面中的鏈接不工作了,我可以擺脫resetpassword行動名稱?如何在MVC表單發佈後刪除URL中的操作名稱
我所指的鏈接是這個鏈接是我的索引頁:
@Html.ActionLink("Forgot Password", "forgotPassword", new { controller = "Home" } , new { id = "btn-forgot-password"})
由於所有的代碼都是模態是在索引頁。
我使用MVC形式後,這是我的方法:
[HttpGet]
[Route("resetpassword")]
[AllowAnonymous]
public async Task<ActionResult> ResetPassword(ResetPasswordRequest resetPasswordRequest)
{
.....
return View("ForgotPasswordError");
}
else
{
.......
return View("Index", logInRequest);
}
}
}
catch (Exception)
{
throw;
}
return View("Index", logInRequest);
}
[HttpPost]
[Route("resetpassword")]
public async Task<ActionResult> ResetPassword(ResetPasswordViewModel resetPasswordViewModel)
{
....
if (ModelState.IsValid)
{
......
}
}
else
{
ModelState.AddModelError("", "Please enter the same value again.");
return View(resetPasswordViewModel);
}
}
else
{
ModelState.AddModelError("", "Password is Required Field.");
return View(resetPasswordViewModel);
}
LogInRequest logInRequest = new LogInRequest();
logInRequest.IsThankYouPage = true;
return View("Index", logInRequest);
}
這是張貼查看:
@model Models.LogInRequest
<link href="~/Content/Styles/ModalStyle.css" rel="stylesheet" />
<link href="~/Content/Styles/style.css" rel="stylesheet" />
@{
Layout = "~/Views/Shared/MasterLayout.cshtml";
}
@if (Model != null && Model.IsResetPassword)
{
<div class="page resetPassword">
@using (Html.BeginForm("resetpassword", "Home", FormMethod.Post))
{
@Html.AntiForgeryToken()
<div class="modal">
<div class="modal-content">
<span class="close">X</span>
<h2 id="modal-title">Reset Your Garage Password</h2>
<hr />
<div>
<div class="create-user-label">Email Address</div>
<div><input type="email" name="Email" placeholder="[email protected]" class="create-new-password-textbox-grey" readonly [email protected] /></div>
<div class="create-user-label">Password</div>
<div><input type="Password" id="Password" name="Password" placeholder="Create Password" class="create-new-password-textbox" onblur="validatePassword();" /></div>
<div id="resetPassword-default-message" class="resetPassword-default-message">Password must be at least 8 characters.</div>
<div id="resetpassword-message"><label class="resetpassword-error" id="password-error"></label> </div>
<div class="create-user-label">Confirm Password</div>
<div><input type="Password" name="ConfirmPassword" id="ConfirmPassword" placeholder="Re-enter Password" class="create-new-password-textbox" onblur="validateConfirmPassword();" /></div>
<div id="confirmPassword-message"><label class="resetpassword-error" id="confirmPassword-error"></label> </div>
<br />
<div>
<input type="submit" id="btnSubmit" value="Submit" class="orange-button create-password-button-half" onclick="validatePasswordSubmit();" />
<input type="hidden" value="@Model.Token" name="token" />
</div>
</div>
</div>
</div>
}
</div>
}
@if(Model.IsThankYouPage)
{
<div id="ThankYou-Page" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="close">x</div>
<div id="reset">
<div class="modal-heading">Success!</div>
<hr class="forgot-password-line" />
<br />
<p>Your password has been successfully reset. Please sign in.</p>
<br />
</div>
</div>
</div>
<script type="text/javascript">
renderThankYouPage();
</script>
}
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/User/CreatePassword.js"></script>
你指的是什麼'鏈接'? (你的問題是沒有意義的) –