0

I am using an ajax PageMethod to call an asp.net webmethod. From there I'm trying to pass a lot of XML back to a callback javascript function.

Currently I just convert the XML into a string and pass it in that format. But it seems that if the string is too long it causes an error.

Here's the VB:

<System.Web.Services.WebMethod()> _
Public Shared Function getXML() As String
   Dim strXML
   strXML=getLoadsOfXML().InnerXml;
   Return strXML
End Function

Here's the javascript:

function loadGrid(){
    PageMethods.getXML(myCallback);
} 

//This function doesn't get called if strXML is too long
function myCallback(strXML){
    useXML(strXML);
}

Here's the error:

Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'getXML' failed with the following error: System.InvalidOperationException-- Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

So my question is: Is there a better way to pass the XML from VB to javascript, or a way to allow large strings to be passed without error?

madth3
  • 7,275
  • 12
  • 50
  • 74
Urbycoz
  • 7,247
  • 20
  • 70
  • 108

1 Answers1

1

This question appears to be what you want, but according to the answer the default value is 4MB. I would look into if you really want to be returning so much data to the client (just imagine someone on a very slow internet connection).

Community
  • 1
  • 1
dbb
  • 1,100
  • 6
  • 12
  • For some reason the default was much lower for me. Increasing it to 4MB seemed to do the trick. Thanks! – Urbycoz Jul 30 '11 at 15:13