2

I am getting trouble editing the data in grid. The data is not selected in this case. It throws an error and while clicking link http://localhost:39302/FlightInfo/GetFlightStatusById?FId=1462 it throws error. Let me know the issue behind this. Thanks in advance.

public JsonResult GetFlightStatusById(int FId)
{
    tblFlightSchedule model = db.tblFlightSchedules.SingleOrDefault(x => x.FId == FId);
    string value = string.Empty;

    value = JsonConvert.SerializeObject(model, Formatting.Indented, new JsonSerializerSettings
    {
        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
    });

    var jsonResult = Json(value, JsonRequestBehavior.AllowGet);
    jsonResult.MaxJsonLength = int.MaxValue;
    return jsonResult;
}

JS:

function EditFlightRecord(FId) {
    debugger;
    var url = "/FlightInfo/GetFlightStatusById?FId=" + FId;
    $("#ModalTitle").html("Update Flight Status");
    $("#MyModal").modal();
    $.ajax({
        type: "GET",
        url: url,
        success: function (data) {
            var obj = JSON.parse(data);
            $("#FId").val(obj.FId);

The following error occurs: An exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll but was not handled in user code. The function evaluation was disabled because of an out of memory exception.

  • What is the return type of db.tblFlightSchedules in your code?? – Ipsit Gaur Jul 02 '18 at 10:54
  • if it worked yesterday and is not working today, without any code/environment changes then you should read this: [link](https://stackoverflow.com/questions/1153702/system-outofmemoryexception-was-thrown-when-there-is-still-plenty-of-memory-fr) – BossRoss Jul 02 '18 at 10:57
  • @AshokBhattarai That doesn't answer my question, my doubt is db.tblFlightSchedules returns all the data in the DB which could cause to OutofMemoryException if you have too much records in DB to be loaded at once in memory – Ipsit Gaur Jul 02 '18 at 10:57

1 Answers1

2

Add following setting in Your web.config. and try to build your code against 64 bit

<gcAllowVeryLargeObjects    
   enabled="true" />  

By default it behave like this. I think that's why you are getting error

From the doc:

<gcAllowVeryLargeObjects    
  enabled="true|false" />

[...]

Value Description

false Arrays greater than 2 GB in total size are not enabled. This is the default.

true Arrays greater than 2 GB in total size are enabled on 64-bit platforms.

Community
  • 1
  • 1
ArunPratap
  • 4,816
  • 7
  • 25
  • 43
  • Please have a look issue with response. https://stackoverflow.com/questions/51820293/increase-the-response-speed-in-jquery?noredirect=1#comment90594986_51820293 –  Aug 13 '18 at 16:40