问题描述: 当使用ASP.NET MVC中的BeginForm方法以POST方式发送数据时,服务器端接收到的数据为空。
解决方法:
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post))
{
}
[HttpPost]
public ActionResult ActionName(string fieldName)
{
// 处理接收到的数据
return View();
}
public class MyModel
{
public string FieldName { get; set; }
}
[HttpPost]
public ActionResult ActionName(MyModel model)
{
// 处理接收到的数据
return View();
}
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
// 表单内容
}
以上是一些常见的解决方法,如果问题仍然存在,请检查网络请求和服务器端日志以查找更多的错误信息。