Possible Duplicate:
Can I set an unlimited length for maxJsonLength in web.config?
I have a script in my .aspx page that is sending info to the back-end .cs page. Concept is simple and worst for most occasions, except when data is too large. How can I increase the capacity of what the "data" variable can hold without modifying web.config? Please see code below.
.ASPX
<script type="text/javascript">
$(document).ready(function () {
var note = "";
for (var i = 0; i < 200000; i++)
note = note + "x";
$.ajax({
type: "POST",
url: "GroupDetailsDisplayPlus.aspx/UpdateRecord",
data: "{note: \"" + note + "\"}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
var response = msg.d;
alert("success");
}
error: function (request, status, thrownError) {
//alert(request.thrownError); // short version
alert(request.responseText); // long version
}
});
});
</script>
.CS
[System.Web.Services.WebMethod]
public static string UpdateRecord(string note)
{
return note;
}
This code is simplified and my purpose is to store this large string in a database (code ommited). If I set the for loop to only do 100,000 cycles this works. However increasing it to 200,000 cycles fails with an error message:
{"Message":"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.\r\nParameter name: input","StackTrace": at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScript Serializer.Deserialize[T](String input)\r\n at System.Web.Script.Service.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}
Thank you for any and all help.