The following code works:
@using (Html.BeginForm("MyAction", "MyController", FormMethod.Post, new { enctype = "multipart/form-data", data_ajax = "false" }))
{
@Html.AntiForgeryToken()
<input type="file" name="UploadedFile" />
<input type="submit" value="Upload" class="btn btn-primary" />
}
If I do Request.Files.Count
I'll have 1 file in (given that I actually submitted a file in the form, of course), but if I change the data_ajax
attribute to true
, I never get a file (count is 0), neither through the Request.Files.Count
, not through a parameter (where the list would be null) (ie:)
public ActionResult MyAction(IEnumerable<HttpPostedFileBase> files) {...}
Can anyone explain to me why does one actually submit the right form (with a file), but the other excludes the file from the request?