0

I have to send unlimited JSON data from ajax J query to MVC razor controller. The method is triggered once we send limited data. if i send more data the method is not triggered and Am getting 500 Internal error.

        $.ajax({
                            url: '../Offline/Save',
                            data: JSON.stringify(Item),
                            data: "{'Id':" + Results.rows.item(m).Id + ",'Item':" + JSON.stringify(Item) + "}",
                            type: 'POST',
                            dataType: "json",
                            contentType: "application/json; charset=utf-8",
                            success: function (data, status) {
                                alert(data);
                                }
                            },                                
                            error: function (xhr, ajaxOptions, thrownError) {
                                console.log(xhr.status);
                                console.log(thrownError);
                            }
                        });


    [HttpPost]
    [ValidateInput(false)]
    public JsonResult SaveFinding(int Id, SyncItem Item)
    {
        Result result = new DB().Process(Id, Item);
        return Json(result);
    }
muthuvel
  • 1,092
  • 10
  • 17

1 Answers1

0

have you tried debugging ?

Is the method SaveFinding() itself not throwing the error ?

Or is it after the method is completed you are getting the error ?

Here are a few links that you should consider looking at

Can I set an unlimited length for maxJsonLength in web.config?

http://binoot.com/2008/10/14/using-json-some-observations/

http://support.microsoft.com/kb/981884

http://dotnetbyexample.blogspot.com/2007/11/expanding-lenght-of-json-data-returned.html

Community
  • 1
  • 1
Yasser Shaikh
  • 46,934
  • 46
  • 204
  • 281
  • yes. I have tried debugging. the pointer moved to this method when the content is low otherwise there is no response But i got this error in the event viewer --> Exception information: Exception type: ArgumentException Exception message: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. We can set maxlength when the control from controller using serializer But how to set teh control from JQuery ajax to controller. – muthuvel Apr 09 '12 at 11:17
  • I have added jsonmaxlength setting in web.config and also added following code even it is not working var serializer = new JavaScriptSerializer(); serializer.MaxJsonLength = Int32.MaxValue; var result = new ContentResult { Content = serializer.Serialize(new FindingDB().SynFinding(new DB().Process(Id, Item))), ContentType = "application/json" }; return Json(result); – muthuvel Apr 09 '12 at 13:15
  • This code is useful to send maximum text from controller to client. But i want from client to controller. I have to send more data from ajax post method to controller. – muthuvel Apr 09 '12 at 13:18