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

后端 未结 4 1434
情歌与酒
情歌与酒 2021-01-13 09:19

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

相关标签:
4条回答
  • 2021-01-13 09:49

    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.

    0 讨论(0)
  • 2021-01-13 09:56

    As none of above worked for me so I used this-

    JsonResult result = Json(<your result>, JsonRequestBehavior.AllowGet);
    result.MaxJsonLength = int.MaxValue;
    return result;
    
    0 讨论(0)
  • 2021-01-13 09:59
    <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.

    0 讨论(0)
  • 2021-01-13 10:11

    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>`
    
    0 讨论(0)
提交回复
热议问题