title: Return large string from ajax call using Jquery to Web Method of ASP.NET
body: <p>Inside my ASP.NET website I am calling a Web Method using Jquery as follows:</p>
  
  <pre><code> $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      data: "{'param1': '" + param1 + "','param2': '" + param2+ "' }",
      dataType: 'json',
      url: "Default.aspx/TestMethod",       
      error: function (jqXHR, textStatus, errorThrown) {
          alert("error: " + textStatus);                     
      },
      success: function (msg) {
          document.getElementById("content").innerHTML = msg.d;
      }
  });  
  </code></pre>
  
  <p>Web Method Definition is:</p>
  
  <pre><code>[System.Web.Services.WebMethod]
  public static String TestMethod(String param1, String param2)
  {       
       String to_return = /* result of operations on param1 and param2 */;        
       return to_return;
  }
  </code></pre>
  
  <p>My result is a String containing HTML code.<br>
  It is working perfect if the <code>to_return</code> string is small.<br>
  But it is giving me error as:</p>
  
  <blockquote>
    <p>500 Internal Server Error 6.22s</p>
  </blockquote>
  
  <p>I tried to explore it using FireBug in Response it shows me:</p>
  
  <blockquote>
    <p>{"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}  </p>
  </blockquote>
  
  <p>Using breakpoints in Visual Studio, I have copied the <code>to_return</code> string into a text file. Size of the file became: 127 KB.<br>
  What possibly went wrong?</p>