我的按钮似乎不适用于 MVC 控制器,我做错了什么?

My button doesn't seem to work with MVC controller, what am I doing wrong?

我想让我的保存按钮更新数据库中的字符串。由于某种原因,它不起作用。

控制器操作:

[HttpPost]
public ActionResult UpdateTemplateBody(TemplateViewModel data)
{
    templateService.UpdateTemplateBody(data.Id, data.Html);
    return RedirectToAction("Index", "TemplateEditor", new { id = data.Id });
}

Html 来自视图:

@using (Html.BeginForm("UpdateTemplateBody", "TemplateList"))
{
    @Html.TextAreaFor(a => a.Html, new { id = "Editor" })

    <br />
    <input class="btn btn-default" id="save" type="button" value="Save" />
}

而不是<input type="button" />

使用:<input type="submit" />

@using (Html.BeginForm("UpdateTemplateBody", "TemplateList"))
{
    @Html.TextAreaFor(a => a.Html, new { id = "Editor" })

    <br />
    <input class="btn btn-default" id="save" type="submit" value="Save" />
}

还要确保您的控制器名称在以下位置是正确的 (TemplateListController):

Html.BeginForm("UpdateTemplateBody", "TemplateList")