I am trying to pass multiple pdf files to the controller method. This is my code in javascript:
var formData = new FormData();
formData.append("data", JSON.stringify(data));
formData.append("httpPostedFileBase", file1, "ff2.pdf");
formData.append("httpPostedFileBase", file1, "ff1.pdf");
$.ajax({
type: "POST",
url: "@Url.Action("GetFiles", "FileUpload")",
data: formData,
dataType: 'json',
contentType: false,
processData: false,
success: function () {
console.log("5");
},
error: function () {
alert('Failure to send request');
}
});
And this is in the controller:

public ActionResult GetFiles(HttpPostedFileBase[] httpPostedFileBase, string data) {
try {
if (Request.Files.Count > 0) {
//...
I get a "Failure to send request" alert right away:

It does not even reach the controller method.
However, works fine if I only try to append a single file. The funny thing is that I've written this functionality in a different project and it works well there.
I tried passing an array of blobs instead of appending them one by one to formData but that did not work either. Any help would be appreciated.
Since another project of yours is working, could it be that you forgot to set an explicit max request size limit in this one? It happened on some projects that the combined file size exceeded max request limit for .NET allowance.
It might require various steps as shown here:
Try checking this
"By default, ASP.NET Core allows you to upload files up of (approximately) 28 MB in size"
In the configuration of the applications (either Startup.cs if you're on <= .NET 5 or Program.cs starting from .NET 6):
But also on IIS Side (remember when you're going to deploy):
In the article also explains how to behave for kestrel servers.