Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON Maximum length problem with ASP.NET

I am creating a asp.net 2.0 webservice which give json as output and there's a very large, can't be break down, dataset which exceed the max length limit

I have search on the internet, and there's solution on .net 3.5 & 4, but not 2.0.

Can any tell me how can I increase the JSON legth limit?

like image 896
Chito Cheng Avatar asked Jul 28 '11 13:07

Chito Cheng


People also ask

What is the max JSON length?

The maximum length of JSON strings. The default is 2097152 characters, which is equivalent to 4 MB of Unicode string data.

Can I set an unlimited length for MaxJsonLength?

The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k).

What is MaxJsonDeserializerMembers?

MaxJsonDeserializerMembers. All data is send as JSON objects in the DocumentViewer client-server communication. The number of properties in a posted JSON object needs to be adjusted using the aspnet:MaxJsonDeserializerMembers application setting: Cannot embed source code.


1 Answers

I had this same exact problem. Was getting frustrated seeing 3.5 and 4.0 solutions. Turns out you do the same thing, you just have to add a couple lines to the <ConfigSections> tag in your Web.config. It should be the first element under the root when you paste it in.

<configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
        <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
            <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
            </sectionGroup>
        </sectionGroup>
    </sectionGroup>
</configSections>

and then add in the actual <system.web.extensions> section:

<system.web.extensions>
  <scripting>
    <webServices>
      <jsonSerialization maxJsonLength="50000000"/>
    </webServices>
  </scripting>
</system.web.extensions>
like image 171
tedski Avatar answered Sep 19 '22 23:09

tedski