Is there any limit to Hidden Field Length in ASP.net

11,035

Solution 1

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">

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

Solution 2

I ran into this problem when I was passing back and forth a large amount of data for mapping - I was losing the data after it got too large. I made some changes to the web.config:

 <appSettings>    
     <add key="aspnet:MaxHttpCollectionKeys" value="5000" />
     <add key="aspnet:MaxJsonDeserializerMembers" value="5000" />
</appSettings>
Share:
11,035
Taha Rehman Siddiqui
Author by

Taha Rehman Siddiqui

To know more about me, find me on LinkedIn.

Updated on June 09, 2022

Comments

  • Taha Rehman Siddiqui
    Taha Rehman Siddiqui almost 2 years

    I am experiencing a strange error (not very strange, i guess it is because of some maximum length restriction i might not know about). I am working on a Custom Server Control, which renders a Custom Search Service for employees. When the employees are searched successfully, I fetch their whole objects (List) from WCF service in json, keep the string in a hidden field, and postback for the code behind to fetch json string and deserialize into objects. Now, up to 2000 objects, it was working flawlessly, but when the search criteria started fetching above 2000, the following error started occuring

    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 
    

    I debugged the code as well, but the c# code was not even catching any calls. I also tried keeping the json strings of objects in multiple hidden fields with each having 1000 records in json string. But still, the error keep coming up. This tells me there is some sort of restriction of maximum size to the form. Can i get any solution for this problem, or do I have to go with sending Ids to the code behind and fetching the Objects from the Service there? Actually, the service url is supposed to be dynamic, the host application would be providing it, so I am trying not to introduce any service binding on C# level(you get the idea, i guess).