Controllers:
public ActionResult Index()
{
return View(db.GuestBooks.ToList());
}

//
// GET: /Guest2/
[HttpPost]
public ActionResult Index(string UserName)
{
ViewData.Model = UserName;
return View();
}


//
// GET: /Guest2/
[HttpPost]
public ActionResult Index(GuestBookInfo gInfo)
{
ViewData.Model = gInfo;
return View();
}

 

view:


<form method="post">
<div>
<ul>
<li>ID:</li>
<li><input type="text" /></li>
</ul>
</div>
</form>

点击提交访问后,报错:

对控制器类型“Guest2Controller”的操作“index”的当前请求在下列操作方法之间不明确: 
类型 Mvc4Study.Controllers.Guest2Controller 的 System.Web.Mvc.ActionResult Index(System.String)
类型 Mvc4Study.Controllers.Guest2Controller 的 System.Web.Mvc.ActionResult Index(Mvc4Study.Models.GuestBookInfo)

 

解决方法:

修改操作名称

 [ActionName("info")]

public ActionResult Index(GuestBookInfo gInfo)

相关文章:

  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2022-01-01
  • 2022-12-23
猜你喜欢
  • 2021-11-22
  • 2022-01-01
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
相关资源
相似解决方案