Hello everyone
I have asp.net mvc project
When I call function from ajax that get big data I set
maxjsonlength in c# controller and it works fine
but when i wont to save that data and wont call function with big object parameter i Get error that can not deserialize big json data
it use javascriptserializer and there where default value
how change it from ajax call
Jaimin ShethiyaPosted Apr 29, 2024, 4:24 AM
Hello Karlen,
Add below code in your web.config file.
Or refer below links
https://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config
https://stackoverflow.com/questions/12750689/setting-jsonserialization-maxjsonlength-in-asp-net-web-config-gives-500-error
https://stackoverflow.com/questions/63332780/how-do-i-increase-size-of-maxjsonlength-for-web-api-method-input-parameter
Thanks
Jignesh KumarPosted Apr 28, 2024, 10:39 AM
Hello Karlen,
Please refer to this one,
if you are using MVC application then please do needful in your start up method,
Prasad RaveendranPosted Apr 28, 2024, 4:10 AM
For ASP.NET MVC applications, you can handle large JSON data differently. You can send large JSON data as a string and deserialize it on the server-side. Here's how you can modify your AJAX call to send the data as a string:
In the controller action (
test/savedata), receive the JSON data as a string and deserialize it:Karlen SahakyanPosted Apr 27, 2024, 9:47 PM
For example in this call I get maxjsonlength error
but in server side I config maxjsonlength
Prasad RaveendranPosted Apr 27, 2024, 6:03 PM
To handle large JSON data in your ASP.NET MVC project when sending it from JavaScript to your controller action, you need to make sure that both the client-side and server-side configurations are set appropriately.
At client side , by using
JSON.stringify(jsonData), you're converting your JSON object to a string before sending it.At Server Side, consider increasing the
maxJsonLengthproperty in yourWeb.configfile.In your
Web.config, add or modify the following entry under:To use
JsonSerializerinstead ofJavaScriptSerializerin your controller action, you can make use of theSystem.Text.Jsonnamespace which provides more modern and efficient JSON serialization/deserialization capabilitiesif you could share your codesnoppet, which would help us to take a look and suggest