0

我正在使用 MVC 3 和 C# 我想知道如何检索使用 POST 发送的表单的值。

她是我的代码,但不起作用,eventTitle 的值为 null。知道我在这里做错了什么吗?谢谢你的时间。

  [HttpPostAttribute]
    public JsonResult AddEventCustom()
    {

            string eventTitle = Request.Form["EventTitle"];

            return Json(new { Message = "Success" }, JsonRequestBehavior.AllowGet);


        }
4

1 回答 1

2

您可以简单地将所需的变量放在方法声明中。MVC `将为您处理映射

[HttpPostAttribute]
public JsonResult AddEventCustom(string EventTitle) 
{ 
}
于 2012-08-20T08:52:21.800 回答