2

I met a issue which is the Ajax could not post a more than 125 rows of data to the corresponding action in the ASP.NET MVC4. When the row count is less than 125, everything could be OK. So it's strange here.

[JS Ajax]

$("#btnExport").click(function () {
    var rows = $("#List").datagrid("getRows"); 

    $.ajax({
        url: "/SysException/Export?sysExceptionModels",
        data: JSON.stringify(rows), 
        type: "POST",
        contentType: 'application/json; charset=utf-8',
        success: function (data) {
        if (data.type == 1) {
            $("#aExportExcel")[0].click(); 
            $.messageBox5s('提示', data.message);
            } else {
            $.messageBox5s('提示', data.message);
            }
        }
    });
});

[ASP.NET MVC4]

    static List<SysExceptionModel> _sysExceptionModelModels = null;

    [HttpPost]
    public JsonResult Export(List<SysExceptionModel> sysExceptionModels)
    {
        _sysExceptionModelModels = sysExceptionModels;
        if (_sysExceptionModelModels == null)
        {
            return Json(JsonHandler.CreateMessage(0, "no data,could not export!"), JsonRequestBehavior.AllowGet);
        }
        else
        {
            return Json(JsonHandler.CreateMessage(1, "export sucessfully!"), JsonRequestBehavior.AllowGet);
        }
    }

one row is like below:

0000688A-85F5-4F72-BE86-85BCADED2DE NULL BBBB BBBB BBBB BBBB BBBB 2015-10-22 02:27:38.000

1 Answer 1

1

You probably are exceeding the max serialization size. Try increasing the MaxJsonDeserializerMembers value in your web.config. Default value is 1000, which might be a bit too small. 150000 might be a better value:

<appSettings>
    <add key="aspnet:MaxJsonDeserializerMembers" value="150000" />
</appSettings>
Sign up to request clarification or add additional context in comments.

2 Comments

It works,appreciate.BTW,for the class JavaScriptSerializer,when i use its method named 'Serialize', I also met the exceeding the max serialization size issue.Should I add the extensions like below?<system.web.extensions> <scripting> <webServices> <jsonSerialization maxJsonLength="2147483644"/> </webServices> </scripting> </system.web.extensions>
A different topic; I think this post answers your last question: stackoverflow.com/questions/5692836/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.