【发布时间】:2012-11-18 15:31:14
【问题描述】:
在我的 MVC 应用程序中,我将以下代码用于文件。
型号
public HttpPostedFileBase File { get; set; }
查看
@Html.TextBoxFor(m => m.File, new { type = "file" })
一切正常......提交价值但我正在尝试从不工作的控制器模型加载文件
控制器
public ActionResult ManagePhotos(ManagePhoto model)
{
if(ModelState.IsValid)
{
//upload file
}
else
{
return View(model); //contains type HttpPostedFileBase File { get; set; }
}
}
如果我的验证失败,我如何再次加载文件输入,因为返回后,我的文件控件没有映射到模型到文件并且它是空的...
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 file-upload razor model