我正在研究一个示例mvc项目,其中我试图将数据发布到控制器。我已经张贴示例(见下文),但如果我添加[HttpPost]方法,我得到'404'错误。Asp.net MVC - 将数据发布到控制器
查看:
<% using (Html.BeginForm()) { %>
<%= Html.Telerik().NumericTextBox()
.Name("NumericTextBox")
.Spinners(false)
.EmptyMessage("ID")
%>
<input type="submit" value="Submit" />
<% } %>
控制器:
[HttpPost]
public ActionResult GetDetails(int id)
{
return View();
}
**I also tried,**
[HttpPost]
public ActionResult GetDetails(FormCollection collection)
{
return View();
}
路线:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Customer", action = "GetDetails", id = UrlParameter.Optional } // Parameter defaults
);
它很典型地找到问题所在。你能否粘贴你的视图和控制器的整个代码? –