Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
305 views
in Technique[技术] by (71.8m points)

asp.net mvc 4 - ajax error 500 & Internal Server Error in MVC

I used ajax method to call the controller and fetch the data and convert it to json or list and set a jquery DataTable. With 1000 records it's working fine, but when I fetch more than 5000 records, ajax method gives me:

500 Internal server error

Here is my code:

 $('#btnAllData').click(function () {

    $.ajax({
        url: 'PartMaster/GridLoad',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (Result) {
            debugger;
            var pageload = Result.split('|');
            var status = (pageload[0])

            if (status == "ERROR") {
                Error(pageload[1]);

            }
            else {
                var Partdetails = (pageload[0]);
                //var LocDetails = JSON.parse(pageload[2]);

            }

            //gridDetails(status1);

        },

        error: function (xhr, ajaxOptions, thrownError) {
            alert(xhr.status);
            alert(thrownError);
        }
    });


});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. check how much time your database is taking to returning data.
  2. Set length of web response ( You can adjust the JSON response size in the web.config with ).

    <configuration>
    <system.web.extensions>
        <scripting>  
             <webServices>                                                   
                 <jsonSerialization maxJsonLength="1000000" />                 
             </webServices>
        </scripting>
    </system.web.extensions>
    </configuration>
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...