【发布时间】:2019-02-25 13:59:34
【问题描述】:
我有一个表格:
@model TodoItem
<form asp-action="/Todo/AddItem" method="POST">
<label asp-for="Title">Add a new item:</label>
<input asp-for="Title">
<button type="submit">Add</button>
</form>
我在 Index.html 中调用它
@await Html.PartialAsync("AddItemPartial", new TodoItem())
在按钮点击时调用控制器:
public async Task<IActionResult> AddItem(TodoItem newItem)
{
//code that calls service...
}
我从来没有在 AddItem 上遇到断点,我读到它可能是由于 _ViewImports.cshtml 不在同一个文件夹中或者它没有包含 @addTagHelper 而导致的 asp-action 未触发。尝试了这些解决方案,但没有奏效。
任何帮助将不胜感激。
【问题讨论】:
标签: c# asp.net-core asp.net-core-mvc