0

I am trying to send image using ajax post to asp.net web form

function SubmitFunction() {            
            alert(imgData_Based64String);
            imgData_Based64String = "test";
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "WebForm1.aspx/SaveImage",
                data: "{ 'Based64BinaryString' :'" + imgData_Based64String + "'}",
                dataType: "json",
                success: function (data) {

                },
                error: function (result) {
                    alert("Error");
                }
            });
        }


    [System.Web.Services.WebMethod]
    public static void SaveImage(string Based64BinaryString)
    {
        string Value = Based64BinaryString;
    }

Everything is ok.
"test" message arrived to server side SaveImage function.
But when I tried to send actual based64string (After removing "test" dummy message)

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10 ....

It never reach to server side SaveImage function. It only show below error at Browser developer mode.

Failed to load resource: the server responded with a status of 500 (Internal Server Error) 
Frank Myat Thu
  • 4,448
  • 9
  • 67
  • 113

2 Answers2

5

Finally I can solve it, after getting help from this link and another link .

<configuration> 
   <system.web.extensions>
       <scripting>
           <webServices>
               <jsonSerialization maxJsonLength="50000000"/>
           </webServices>
       </scripting>
   </system.web.extensions>
</configuration> 
Community
  • 1
  • 1
Frank Myat Thu
  • 4,448
  • 9
  • 67
  • 113
1

If I'm not mistaken there is a limit in ASP:

http://msdn.microsoft.com/en-us/library/system.xml.xmldictionaryreaderquotas.maxstringcontentlength%28v=vs.110%29.aspx

Apparently you can set it.

Not sure if it implies to your specific situation though. But it seemed relevant

Matt
  • 1,081
  • 15
  • 27