0

设置: 我正在处理reset password页面并计划有一个视图来一个接一个地显示三个表单。

最初将要求用户输入用户名,然后提交表单。我能够捕捉到它是HttpPost动作方法。

我返回相同的视图,但这次我呈现不同的形式,我正在使用Razor

当我尝试从我现在显示的第二种表单提交(调用不同的操作方法)时,我收到错误消息说找不到资源

问题: 是否不能从示例页面/视图回发两次?如果可能的话,我该如何实现?

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");
}
4

0 回答 0