我正在使用MVC 3和C#我想知道如何检索使用POST发送的表单的值。
她的代码,但不起作用,eventTitle的值为null。知道我在这里做错了吗?谢谢你的时间。
[HttpPostAttribute]
public JsonResult AddEventCustom()
{
string eventTitle = Request.Form["EventTitle"];
return Json(new { Message = "Success" }, JsonRequestBehavior.AllowGet);
}
答案 0 :(得分:2)
您可以在方法声明中简单地放置所需的变量。 MVC`将为您处理映射
[HttpPostAttribute]
public JsonResult AddEventCustom(string EventTitle)
{
}