setting jsonSerialization maxJsonLength in ASP.net Web.Config gives 500 error

浪尽此生 提交于 2019-12-01 06:11:01

The problem for me was that I put the code in the beginning of the web.config. For some reason, putting it at the end worked.

Not an expert, so I have no idea why that worked.

It worked without the last two code sections that I tried to make it work.

madhu_sudhan

I agreed with Gracchus, I put this below block in end of web.config file

<system.web.extensions>
    <scripting>
        <webServices>
            <jsonSerialization maxJsonLength="2147483647"/>
        </webServices>
    </scripting>
</system.web.extensions>`
<system.web.extensions>
    <scripting>
      <webServices>
        <!--<jsonSerialization maxJsonLength="50000000">
        </jsonSerialization>-->
        <jsonSerialization maxJsonLength="500000000">
          <!--50000000-->
        </jsonSerialization>
      </webServices>
    </scripting>
  </system.web.extensions>  

Above settings worked for me. Additionally i had to set the target framework of the website to .Net 4.0. This web config setting was giving me 500 error when the target framework was set to .Net 2.0

To change the framework, goto IIS and select Application Pool Right click on your website name and select Advanced settings. Here you can change the .Net Framework Version by clicking on the drop-down.

Also i had this setting at the bottom of the web config. Only for good luck :)

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!