2011-07-28 68 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>