简体   繁体   English

Ajax如何将大数据发布到asp.net Web表单webMethod

[英]How Ajax post large data to asp.net web form webMethod

I am trying to send image using ajax post to asp.net web form 我正在尝试使用ajax发布将图像发送到asp.net Web表单

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. “测试”消息到达服务器端SaveImage函数。
But when I tried to send actual based64string (After removing "test" dummy message) 但是当我尝试发送实际的based64string时(删除“ test”虚拟消息后)

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

It never reach to server side SaveImage function. 它永远不会到达服务器端的SaveImage函数。 It only show below error at Browser developer mode. 它仅在浏览器开发人员模式下显示以下错误。

Failed to load resource: the server responded with a status of 500 (Internal Server Error) 

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> 

If I'm not mistaken there is a limit in ASP: 如果我没记错的话,ASP会有一个限制:

http://msdn.microsoft.com/en-us/library/system.xml.xmldictionaryreaderquotas.maxstringcontentlength%28v=vs.110%29.aspx http://msdn.microsoft.com/zh-cn/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 但这似乎很重要

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM