Search code examples
asp.nettreeviewhtml-tableviewstatehttpexception

ASP.Net Treeview AND HTML Table. Error : Maximum request length exceeded


I am using a treeview in my webpage which is binding approx 2000 records at 4 parent node level:

A : bind child node count =1
B : bind child node count =25
C : bind child node count = 250
D : bind child node count = 1800

On click of these nodes there is a literal control on which I am rendering an HTML table from code behind.

The data displayed in html table for node A is 1 row 20 column.
The data displayed in html table for node B is 25 row 20 column.
The data displayed in html table for node C is 250 row 20 column.
The data displayed in html table for node D is 1800 row 20 column.

When I am rendering these tables on SelectedNodeChenaged event of the treeview. After 4 to 5 selection the page gives an error message. Maximum request length exceeded. System.Web.HttpException: Maximum request length exceeded.

Now I know that the data I am dealing with is quite huge. And I guessed the problem might be with the huge view states.But I am not able to get to a solution. Please help with your suggestions.

Solution Tried are:

1. disabling view state for the treeview :-(
2. disabling view state for the HTML tables rendered on literal control. :-(
3. setting maxJsonLength="5000000" in web.config. :-(

Thanks in Advance.


Solution

  • try this in webconfig

    Browsers, and HTML in general, were never designed to handle large uploads
    gracefully.
    If you need to upload files larger than 4 MB, 
    you can modify the web.config file manually to change the maximum request length
    
    
    <system.web>
      <httpRuntime executionTimeout="240" maxRequestLength="5000000" />
    </system.web>
    

    From MSDN

    Specifies the limit for the input stream buffering threshold, in KB. This limit can be used to prevent denial of service attacks that are caused, for example, by users posting large files to the server.