Encountered an error message stating "Out of Stack Space" while attempting to serialize an ASP.Net AJAX Array object.
Below is a breakdown of the issue with simplified code:
Default.aspx
MainScript.js
function getObject(){ return new Array(); } function function1(obj){ var s=Sys.Serialization.JavaScriptSerializer.serialize(obj); alert(s); } function function2(){ var obj=getObject(); var s=Sys.Serialization.JavaScriptSerializer.serialize(obj); alert(s); }
Content.aspx
ContentScript.js
function serializeObject(){ var obj=window.top.getObject(); window.top.function1(obj); // <– This works fine obj=new Array(); window.top.function1(obj); // <– this causes an Out of Stack Space error }
To view the code for the sample pages and JavaScript, click here.
The code for the ASPX pages couldn't be included here due to limitations. Refer to the link above to access the code for the ASPX pages.
The issue occurs on a web page (default.aspx) with an IFrame hosting a content page (content.aspx).
When clicking the "Serialize Object" button, the JavaScript function serializeObject() is called. Serialization works correctly for Array objects created in the main window (outside the frame). However, if the array object is created within the IFrame, serialization fails with an out of stack space error. The investigation revealed an endless loop in the ASP.Net AJAX JS files, where the system repeatedly attempts to determine the type of the array object. This continuous process triggers repeated calls to Number.IsInstanceOf, leading to the out of stack error.
Do you have any suggestions or solutions for this issue?