defaultmodelbinder

ASP.NET MVC posted file model binding when parameter is Model

二次信任 提交于 2019-11-26 15:48:42
问题 Is there any way to get posted files ( <input type="file" /> ) to take part in model binding in ASP.NET MVC without manually looking at the request context in a custom model binder, and without creating a separate action method which only takes a posted file as input? I would have thought that this would work: class MyModel { public HttpPostedFileBase MyFile { get; set; } public int? OtherProperty { get; set; } } <form enctype="multipart/form-data"> <input type="file" name="MyFile" /> <input

MVC3 Non-Sequential Indices and DefaultModelBinder

南笙酒味 提交于 2019-11-26 05:55:46
问题 Is it true that the default model binder in MVC 3.0 is capable of handling non-sequential indices (for both simple and complex model types)? I\'ve come across posts that suggest it should, however in my tests it appears that it does NOT. Given post back values: items[0].Id = 10 items[0].Name = \"Some Item\" items[1].Id = 3 items[1].Name = \"Some Item\" items[4].Id = 6 items[4].Name = \"Some Item\" And a controller method: public ActionResult(IList<MyItem> items) { ... } The only values that