セットアップ:
私はreset passwordページに取り組んでおり、3 つのフォームを次々に表示する単一のビューを持つことを計画しています。
最初にユーザーはユーザー名の入力を求められ、次にフォームが送信されます。HttpPostアクションメソッドで捉えることができました。
同じビューを返していますが、今回は別のフォームをレンダリングしています。Razor
現在表示している2番目のフォームから送信しようとすると(別のアクションメソッドを呼び出して) 、リソースが見つからないというエラーが表示されます
質問: サンプル ページ/ビューから 2 回ポスト バックすることはできませんか? 可能であれば、どうすれば達成できますか?
CSHTML:
@if (ViewBag.step == 1) {
<form id="frmUsername" action="@Url.Content("~/Account/ValidateAnswers")" method="post" novalidate="novalidate" ng-init="initStep1()">
...
</form>
}
@if (ViewBag.step == 2) {
<form action="@Url.Content("~/Account/ValidateUsername")" id="frmQuestions" ng-init="initStep2()" novalidate="novalidate">
...
</form>
}
コントローラーのメソッド:
public ActionResult RecoverPassword(string userType)
{
ViewBag.step = 1;
ViewBag.userType = userType;
ViewBag.showUsernameErrorMessage = "false";
return View();
}
[AllowAnonymous]
[HttpPost]
public ActionResult ValidateUsername(string userName, string selectedUserType)
{
...
ViewBag.step = responseStep;
ViewBag.showUsernameErrorMessage = responseShowUsernameErrorMessage;
ViewBag.userName = userName;
ViewBag.userType = selectedUserType;
return View("~/Views/Account/RecoverPassword.cshtml");
}
[HttpPost]
public ActionResult ValidateAnswers(string answer1, string answer2, string answer3, string questionId1, string questionId2, string questionId3, string step, string userName, string selectedUserType)
{
...
ViewBag.step = responseStep;
ViewBag.showUsernameErrorMessage = responseShowUsernameErrorMessage;
ViewBag.userName = userName;
ViewBag.userType = selectedUserType;
return View("~/Views/Account/RecoverPassword.cshtml");
}