2011-07-28 63 views
11

我创建一个asp.net web服务2.0这给JSON作为输出,并有一个非常大的,不能被打破,数据集超出最大长度限制JSON最大长度问题ASP.NET

我在互联网上搜索,并有.net 3.5 & 4,但不是2.0的解决方案。

任何可以告诉我如何增加JSON限制?

+0

你有没有得到这个答案? – erlando

回答

13

我有同样的确切问题。看到3.5和4.0解决方案让人感到沮丧。结果你做同样的事情,你只需要添加几行到你的Web.config中的<ConfigSections>标签。当你将其粘贴在它应该是第一个元素的根目录下

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

,然后在实际<system.web.extensions>部分添加:

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