I have a view that has the following file input:
<input type="file" name="SchemaFiles" id="SchemaFiles" class="form-control" multiple/>
My model has this attribute:
public List<HttpPostedFileBase> SchemaFiles { get; set; }
When I select one or two files for this input, everything works fine. However, if I don't select any files and submit the form, then SchemaFiles.Count
is 1
, and SchemaFiles[0]
is null
(but does exist). ModelState.IsValid
is true
.
Is there a way to avoid this?