I have an Controller Action as follows for posting Form Data (Just testing binding atm, comments left in to give you an idea of things I've tried):
[HttpPost]
//[RequestFormLimits(BufferBodyLengthLimit = 2097152000)]
//[RequestSizeLimit(209715200)]
public async Task<IActionResult> ProcessF([FromForm] IEnumerable<FBillingPostDTO> bills)
{
return Json("Success");
}
This Post Action is called via AJAX with the following:
$.ajax({
url: "@Url.Action("ProcessF","Billing")",
type: "POST",
//contentType: "application/json",
dataType: "json",
data: { "bills": promiseArray }
}).done(function () {
location.href = "/F/Manage/"
})
The data binds to the IEnumerable, but only if the submitted collection is of 256 objects or less. Any more than this and the binding returns null with 0 entries.
I thought this may be a maxAllowedContentLength
issue, but after padding the data, it seems to be the number of objects in the submitted array that causes it to return null.
Before I go back to the start and refactor it to avoid this limitation, is there a setting controlling this value? IEnumerable of length 256 seems a bit too much of a coincidence, especially when the ContentLength doesn't cause the problem (i.e. 256 elements @ 36Kb is accepted, but over 256 elements @ 35Kb is rejected)
The application is .Net Core 3.1 running locally on IIS express (Debugging).
I really need to open my eyes more, somehow I missed this in the call stack when debugging , under this.Request.Form
:
"Form value count limit 1024 exceeded"
All it required was adding [RequestFormLimits(ValueCountLimit = xxx)]
annotation to the Action method:
[HttpPost]
[RequestFormLimits(ValueCountLimit = 10000)]
public async Task<IActionResult> ProcessF([FromForm] List<FBillingPostDTO> bills)
{
return Json("Success");
}
So 256 objects of 4 Key Value Pairs = 1024 Values which is the max allowed by default. I need to improve my googling, as this is news to me haha.