viv*_*vid 2 c# asp.net asp.net-mvc-3 asp.net-mvc-5
好的,所以我得到了控制器中的动作,代码是:
[HttpPost]
public ActionResult SaveRow(int? id)
{
//some db operations.
return RedirectToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)
并且在视野中我得到了
@Html.ActionLink(Translation.Accept, "SaveRow", new { id = item.New.RecId })
Run Code Online (Sandbox Code Playgroud)
当我点击按钮可以运行此操作而不重定向到时,我收到错误404 url /SaveRow/?也许这个按钮使用错误我是mvc5的新手,所以请耐心等待.
如此处所述: -
2.指向动作的超链接或锚标记将始终是HttpGet.
尝试下面的代码放GET,因为默认情况下需要[HttpGet]删除[HttpPost]属性
[HttpGet]
public ActionResult SaveRow(int? id)
{
//some db operations.
return RedirectToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)
作为MVC的理想设计,我建议你@Html.BeginForm用来访问POST编辑功能的相应调用
| 归档时间: |
|
| 查看次数: |
840 次 |
| 最近记录: |