小编usF*_*wan的帖子

在具有大量数据的mvc4中的ajax发布期间,系统抛出System.ArgumentException异常

我正在做ajax帖子来发布mvc4中来自javascript的数据,但它失败并出现以下异常

string exceeds the value set on the maxJsonLength property.
Parameter name: input
System.ArgumentException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. 
Run Code Online (Sandbox Code Playgroud)

我已经尝试在Web配置中设置配置但它无法正常工作

<system.web.extensions>
    <scripting>
        <webServices>
            <jsonSerialization maxJsonLength="2147483647"/>
        </webServices>
    </scripting>
</system.web.extensions>  
Run Code Online (Sandbox Code Playgroud)

我也试过下面的链接,但没有任何作用:http: //forums.asp.net/t/1751116.aspx?How+to+increase+maxJsonLength+for+JSON+POST+in+MVC3

var editorText = eval(htmlEditor).GetHtml();     
$.ajax({type: 'POST',
    cache: false,
    contentType: 'application/json; charset=utf-8',
    url: "../Home/SaveExceptionLetter",
    data: JSON.stringify({ message: editorText }),
    datatype: 'json',
    success: function () {
    });
} });

[HttpPost]
[ValidateInput(false)]
public void …
Run Code Online (Sandbox Code Playgroud)

c# ajax asp.net-mvc jquery asp.net-mvc-4

9
推荐指数
2
解决办法
7182
查看次数

标签 统计

ajax ×1

asp.net-mvc ×1

asp.net-mvc-4 ×1

c# ×1

jquery ×1