Hosein
Hosein

Reputation: 581

ASP.NET MVC action is not being called on huge JSON

I use asp.net mvc 2.0 and jquery for my web application. when I tried to call a MVC action by Jquery Ajax with a JSON object about 30K, my server action did not get called. I searched for a solution and changed the maxJsonLength property in web.config. but that didn't work.

I'll appreciate any help.

Upvotes: 0

Views: 2393

Answers (1)

Hosein
Hosein

Reputation: 581

I solved my problem and in case any body has this problem in future, here is the solution.

My actual problem was not the length of the JSON object. It was the numbers of keys in that object. Actually there is a limit for the keys number you can send via the ajax post request in ASP.NET and in case you need more, youe should increase it in web.config appSettings section:

<add key="aspnet:MaxHttpCollectionKeys" value="100000" />

And also don't forget to add these two configs in similar cases to some big numbers:

<appSettings>
  <add key="aspnet:MaxJsonDeserializerMembers" value="10000000" />
</appSettings>

and

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

Upvotes: 3

Related Questions