I have a the following code
ajax call
$.ajax({
type: "POST",
dataType: "json",
async: false,
contentType: "application/json; charset=utf-8",
url: "Account/SomeFunc",
data: JSON.stringify(dataToSend),
success: function (res) {
//some code
},
error: function (res, textStatus, errorThrown) {
//some code
}
});
and on the server-side
public ActionResult SomeFunc()
{
//some code
VeryBigObject result = getResult();
if (result == null)
return null;
var jsonResult = Json(result, JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;
return jsonResult;
}
result variable can be small but sometimes its a very big object. when the object is small enough the code works and the ajax success code is activated but when the result is big enough the code fails with 500 Internal Server Error. I cant put MaxJsonLength any bigger because its an int but sometimes I need to send some big data.. what can I do?