C# MVC RedirectToAction 不更新视图

C# MVC RedirectToAction not updating View

我有一个 C# MVC 网站,它有一个控制器,里面有多个 ActionResult 方法。我有基本的索引,它只加载上面有一个表单的初始页面。用户填写此表单并单击提交。从那里表单被序列化并发送到直接在下面的方法,该方法执行一些操作然后重定向到另一个操作。

    [HttpPost]
    public ActionResult GenerateDegreeAudit(FormCollection formCollection)
    {
        //Do Stuff

        //Then
        return RedirectToAction("Review");
    }

Review 方法,如下所示,遇到了我的断点。

    public ActionResult Review()
    {
        ViewBag.Courses = DegreeAuditRequest.Courses;
        return View();
    }

对应的 Review.cshtml 文件如下所示。

<div class="container">
<div class="row">
    <div class="box box-primary">
        @using (Html.BeginForm("Review", "DegreeAuditProcess", null, FormMethod.Post, new { @class = "form-horizontal", @role = "form", @id = "frmReview" }))
        {
        <div class="box-body">
            <table>
                <thead>
                    <tr>
                        <th></th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var course in ViewBag.Courses)
                    {
                    <tr>
                        <td><input type="text" class="form-control" value="@course.EventName" /></td>
                        <td><input type="text" class="form-control" value="@course.ScheduledTerm" /></td>
                    </tr>
                    }
                </tbody>
            </table>
        </div>
            <div class="box-footer">
                <div class="row">
                    <div style="width: 100%;">
                        <input type="button" class="btn btn-primary" value="Generate" id="btnDAPRocess" style="float: right; margin-right: 10px;" />
                    </div>
                </div>
            </div>
        }
    </div>
</div>

但是页面不会更新以显示 Review.cshtml 文件中的 HTML。我错过了什么?

这个问题的答案非常令人讨厌。它与初始表单的提交方式有关。为了点击 GenerateDegreeAudit,我没有使用 form.submit 而是使用 Ajax 调用。因为这个 MVC 处理 Ajax 与它处理 form.submit 的方式完全不同。使用 form.submit 效果很好。