javascript 从 ASP.NET 页面方法增加最大响应大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5902540/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 18:44:58  来源:igfitidea点击:

Increasing maximum response size from ASP.NET Page Method

c#javascriptjqueryasp.netajax

提问by zmj

I've got a page method on an ASPX page that gets called by a jQuery AJAX POST request. When I try to return too many results, the request fails. Is there a web.config setting or class attribute I can use to increase the default maximum response size?

我在 ASPX 页面上有一个页面方法,它被 jQuery AJAX POST 请求调用。当我尝试返回太多结果时,请求失败。是否有可用于增加默认最大响应大小的 web.config 设置或类属性?

回答by Kelsey

I am assuming you are returning JSON?

我假设你正在返回 JSON?

You can adjust the JSON response size in the web.config with:

您可以使用以下命令在 web.config 中调整 JSON 响应大小:

<configuration>
    <system.web.extensions>
        <scripting>  
             <webServices>                                                   
                 <jsonSerialization maxJsonLength="1000000" />                 
             </webServices>
        </scripting>
    </system.web.extensions>
</configuration>

Doing a quick search, it looks like the default size is 102400.

进行快速搜索,看起来默认大小是 102400。

maxJsonLength Optional attribute.

Configures the maximum length of the JSON string (the maximum number of UTF-8 characters).

The default length is 102400.

maxJsonLength 可选属性。

配置 JSON 字符串的最大长度(UTF-8 字符的最大数量)。

默认长度为 102400。

Source

来源