3

I'm trying to post big json in mvc action method. which result in error

Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. Parameter name: input

I know there're many post on SO and google, i've tried many solution but none of them worked for me:

What I've tried: Updated Web.Config

Updated this statement in system.web

<httpRuntime targetFramework="4.5.1" maxRequestLength="1073741824"  />

and following line in Systerm.webserver

<security>
      <requestFiltering>
                <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
    </security>

after adding above lines it worked for me in local, but after updating same value on server its not working, it throws above error.

Update

IIS Version 7.5
Mox Shah
  • 2,967
  • 2
  • 26
  • 42

2 Answers2

0

Try also adding the following to your web.config

<configuration>
  <system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength="{required length of json in bytes}" />
      </webServices>
    </scripting>
  </system.web.extensions>
</configuration>

The max value is 2147483647 and the default is 102400 (100kb) which may be your issue.

garethb
  • 3,951
  • 6
  • 32
  • 52
0

Have you tried following ways:

  1. Send data as object not like url parameters in ajax call like below.

          $.ajax({
                    type: "POST",
                    url: url,
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(data),
                    dataType: "json",
                    success: function (data) {
    
                    },
                    error: function (a, b, c) { console.log(a); }
                });
    
  2. You can see my POST.

Pang
  • 9,564
  • 146
  • 81
  • 122
Chanikya
  • 476
  • 1
  • 8
  • 22