I have a jquery/ajax call to my web method defined in my C# code behind page in asp.net.
I am trying to return a string array of 2000 items.
I get an undefined error.
If the array is less than 400 it works OK.
So the problem is how I am returning large arrays to the jquery call.
I am returning from my web method this:
string[]
Is there a limit to the amount of items in an array i can return or do i have to parse it somehow to something json accepts?
New at this game so appreciate advice.
//client side
jQuery(function ($) {
$.ajax({
type: "POST",
url: "Feed.aspx/PlayClips",
data: JSON.stringify({
ClipValue: lstMotionClips.options[lstMotionClips.selectedIndex].value,
SessionID: sessionID,
alias: alias
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$.each(msg.d, function () {
if (this['Text'] == "ERROR") {
alert(this['Value']);
}
else {
arrayresult = msg.d;
totalFrames = arrayresult.length;
PlayBack();
}
});
},
error: function (msg) {
alert(msg.d);}
})
});
//server side
[WebMethod]
public static string[] PlayClips(string ClipValue, string SessionID, string alias)
{
string[] frames = null;
try
{
string[] parentDirectory = Directory.GetDirectories(parentPath, guid, SearchOption.AllDirectories);
if (parentDirectory.Length > 0)
{
frames = Directory.GetFiles(parentDirectory[0], "*.jpg", SearchOption.TopDirectoryOnly);
}
}
catch (Exception _ex)
{
dalStatic.AddError("PlayClips." + _ex.ToString());
}
return frames;
}
Thanks
NB I have checked the total length of the string when the error starts.
It appears that a length of string up to 14188 is OK. As soon as I go beyond that I get the error. So, a threshold has been reached. I have set the MaxStringContent toa very high number but still get the error.