【问题标题】:How Ajax post large data to asp.net web form webMethodAjax 如何将大数据发布到 asp.net 网页表单 webMethod
【发布时间】:2014-06-21 15:18:40
【问题描述】:

我正在尝试使用 ajax post 将图像发送到 asp.net 网络表单

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;
    }

一切正常。
“测试”消息到达服务器端 SaveImage 函数。
但是当我尝试发送实际的 based64string 时(删除“测试”虚拟消息后)

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

它永远不会到达服务器端的 SaveImage 函数。 它仅在浏览器开发者模式下显示以下错误。

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

【问题讨论】:

    标签: c# jquery asp.net ajax http-post


    【解决方案1】:

    在得到linkanother link的帮助后,我终于可以解决它了。

    <configuration> 
       <system.web.extensions>
           <scripting>
               <webServices>
                   <jsonSerialization maxJsonLength="50000000"/>
               </webServices>
           </scripting>
       </system.web.extensions>
    </configuration> 
    

    【讨论】:

      【解决方案2】:

      如果我没记错的话,ASP 是有限制的:

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

      显然你可以设置它。

      不确定这是否暗示您的具体情况。但这似乎是相关的

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-04-19
        • 1970-01-01
        • 2012-06-24
        • 1970-01-01
        • 2020-12-09
        • 2017-02-11
        • 2016-11-02
        • 1970-01-01
        相关资源
        最近更新 更多