So, I keep getting the 500 - Internal server error page on my .net site when I set the maxJsonLength in my web.config.
I\'m modifying the .config because even though
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.
As none of above worked for me so I used this-
JsonResult result = Json(<your result>, JsonRequestBehavior.AllowGet);
result.MaxJsonLength = int.MaxValue;
return result;
<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.
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>`