我不能让asp.net mvc 1.0为我绑定HttpPostedFileBase。无法让HttpPostedFileBase在Asp.Net MVC 1.0中正确绑定
这是我的EditModel类。
public class PageFileEditModel
{
public HttpPostedFileBase File { get; set; }
public string Category { get; set; }
}
这是我的编辑方法标题。
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(int id, FormCollection formCollection, PageFileEditModel[] pageFiles)
,这是我的HTML
<input type="file" name="pageFiles[0].File" />
<input type="text" name="pageFiles[0].Category" />
<input type="file" name="pageFiles[1].File" />
<input type="text" name="pageFiles[1].Category" />
分类正确绑定,但文件总是空。
我已验证文件确实在Request.Files
。
的HttpPostedFileBaseModelBinder
默认情况下添加这样也弄不清是怎么回事错..
唯一能想到的就是我的头顶:表单的“enctype”属性是否设置为“multipart/form-data”? – 2010-01-20 14:04:56
是的,我已经验证这些文件确实在Request.Files中。 – 2010-01-20 14:30:46