ajax 向页面返回大量数据超过上限的解决方法

参考网页:https://www.cnblogs.com/ericli-ericli/p/5615644.html

web.config中添加以下内容
<system.web.extensions>
    <scripting>
        <webServices>
            <jsonSerialization maxJsonLength="1024000000" />
        </webServices>
    </scripting>
</system.web.extensions>

说用底下这个方法更完美,我用的是2003也不怎么地JavaScriptSerializer 没new出来。

public ActionResult GetLargeJsonResult()
{
  return new ContentResult
    {
        Content = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }.Serialize(listResult),
        ContentType = "application/json"
    };
}

另外,发现一个讲解更加透彻的帖子,附上地址:http://www.cnblogs.com/artech/archive/2012/08/15/action-result-03.html

猜你喜欢

转载自blog.csdn.net/wxmwzz/article/details/91166436