Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12141

.net 6 Ajax POST Large array results in null parameter

$
0
0

I have built a .net 6 MVC Application which needs to process some data passed from the UI in the form of a table of strings (actually JSON objects but I tried simplifying as much as I could to narrow it down).

Here's my Controller Method:

[HttpPost]public JsonResult LoadData( List<string> inputData){    var success = db.ProcessData(inputData);    return Json(new    {        Success = success    });}

And here is my Javascript call:

var inputData = [];$.each(tableData.body, function (index, item) {    inputData.push(JSON.stringify(jQuery.parseJSON(item[0])));});var data = {    inputData: inputData}$.ajax({    type: "POST",    url: '@Url.Action("LoadData", "myController")',    data: data,    success: function(response) {    },    failure: function(response) {        debugger;    },    error: function(response) {        debugger;    }});

What happens is that it all works fine as long as my array is not too big (I've tried with a few entries and it works), but when I try it with real data (content length is 226601, so not that impressive), the inputData in my controller is null.There is not exception, just the data is nulled.

I encounter this when I debug it in VS2022 with IISExpress.I tried setting some content size limit by adding a web.config file at the root of my project, and I also tried setting MaxRequestBodySize in my Program.cs, but so far nothing has worked.

Is anyone familiar with this ?

EDIT:I just tried to do JSON.Stringify on my array before passing it, and changing the parameter type to string instead of List. Then I'm able to parse it as an array using JArray.Parse(inputData), and all the data seems to be there. Is there a limit to the size of an array you can post ?


Viewing all articles
Browse latest Browse all 12141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>