Maximum request length exceeded postback exception

I get the following exception when a button is clicked, for an asp page that links over 500 entries in gridview when the page loads.

My page does not have load control. It contains a text box, a button and a grid. Does anyone know why this is happening.

Exception Description:

Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
+5
source share
1 answer

Sending sends back to the viewstate of each control - if you have a huge data set, then when the browser passes it to the server, that’s why you get an exception.

Your two options:

  • Set EnableViewState="false"in your GridView if you do not need a viewstate, so it is not so bloated, and postback is a reasonable size,
  • web.config, :

    <configuration>
        <system.web>
            <httpRuntime maxRequestLength="32768" />
        </system.web>
    </configuration>
    

,

+16

All Articles