【发布时间】:2015-01-07 18:29:20
【问题描述】:
我想将复杂模型属性发布到HttpPostedFileBase。
控制器
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(AlbumImagesLoc entity, int albumId, HttpPostedFileBase ImageUrl)
{ }
查看
@Html.TextBoxFor(model => model.AlbumImage.ImageUrl, new { type = "file" })
@Html.ValidationMessageFor(model => model.AlbumImage.ImageUrl)
现在的问题是HttpPostedFileBase 总是null,因为它的名字必须是AlbumImage.ImageUrl。
如何避免 MVC 代码中的null?
【问题讨论】: