点击提交按钮后。我在实体中变为null。 有没有人有解决方案?c#MVC3 ajax.beginform上传文件不起作用
查看
@using (Ajax.BeginForm("CreateRoom", "Room", new AjaxOptions { HttpMethod = "POST", OnComplete = "window.location.href='Index'" }, new { enctype = "multipart/form-data", id = "ajaxUploadForm" }))
{
<input type="file" name="Room" />
<input type="submit" value="OK" />
}
控制器
[HttpPost]
public ActionResult CreateRoom(RoomFileView entity)
{
//code
}
模型
public class RoomFileView
{
public RoomFileView();
public int BuildingId { get; set; }
public int CityId { get; set; }
public int CountryId { get; set; }
public int FloorId { get; set; }
public int LocationId { get; set; }
public HttpPostedFileWrapper Room { get; set; }
public string Content();
}
尝试为的Html.Form,并删除的onComplete ATTR。如果这有效,那么它是一个微妙的。如果不是,它的大东西我们还没有看到... – 2013-02-20 05:17:10
尝试使用'Html.BeginForm'而不是'Ajax.BeginForm' – 2013-02-20 07:01:32