[英]I can't to call action method in the controller from view
我想在“索引”视图提供的链接上从“家庭”控制器调用“删除人”方法,但收到错误:“找不到此资源”:HTTP 404,URL:/ Home / DeletePerson / 1。 我试过@ Html.ActionLink,但它也不起作用。 我的错误在哪里? 该项目有.NET Framework 4.7.2,Entity Framework 6.2.0,MVC 5.这个项目有HomeController:
public class HomeController : Controller
{
...
public ViewResult Index()
{
...
return View("Index");
}
[HttpGet]
public ActionResult DelelePerson(int id)
{
...
return View(person);
}
[HttpPost]
public ActionResult DeletePersonConfirmed(int id)
{
...
return RedirectToAction("Index");
}
}
我的Index.cshtml包括
<td><p><a href="/Home/DeletePerson/@b.Id">Del</a></p></td>
首先,使用Html.ActionLink
创建正确的链接他们知道您的特定路由配置。 其次,您的链接应该看起来像“/Home/DeletePerson?id=@b.id”,但这取决于您尚未发布的路由配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.