ASP.net 中的隐藏字段长度是否有任何限制

Tah*_*qui 4 c# asp.net wcf hidden-field asp.net-customcontrol

我遇到了一个奇怪的错误(不是很奇怪,我想这是因为我可能不知道某些最大长度限制)。我正在开发一个自定义服务器控件,它为员工呈现自定义搜索服务。成功搜索到员工后,我从 WCF 服务中以 json 形式获取他们的整个对象(列表),将字符串保存在隐藏字段中,并回发后面的代码以获取 json 字符串并反序列化为对象。现在,多达 2000 个对象,它完美地工作,但是当搜索条件开始获取 2000 以上时,开始出现以下错误

Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 0 
Run Code Online (Sandbox Code Playgroud)

我也调试了代码,但是 c# 代码甚至没有捕捉到任何调用。我还尝试将对象的 json 字符串保存在多个隐藏字段中,每个字段在 json 字符串中有 1000 条记录。但是,错误仍然不断出现。这告诉我表单的最大尺寸有某种限制。我能得到这个问题的任何解决方案,还是我必须将 Id 发送到后面的代码并从那里的服务中获取对象?实际上,服务 url 应该是动态的,宿主应用程序会提供它,所以我试图不引入任何 C# 级别的服务绑定(我猜你明白了)。

Bri*_*ers 5

ASP.NET does have a maximum request size-- it is 4MB by default, according to the documentation. If you think you might be hitting that limit, you can increase it by adding the following to your web.config file inside the <system.web> tag:

<httpRuntime maxRequestLength="x">
Run Code Online (Sandbox Code Playgroud)

where x is the desired maximum in Kilobytes. So for example, 10240 would be 10MB.