Maximum request length exceeded exception on postback
.net, asp.net
Solution
A postback sends back the viewstate of every control - if you have a huge datagrid, then when the browser reposts that to the server, this is why you are getting the exception.
Your two options are:
- Set `EnableViewState="false"` on your GridView if you do not need the viewstate, so it's not so bloated and the postback is a reasonable size,
Increase the maximum request size in `web.config` as shown below:
<configuration>
<system.web>
<httpRuntime maxRequestLength="32768" />
</system.web>
</configuration>
Hope this helps
Problem
I'm getting the following exception on a button click, for an asp page which binds more than 500 records in a gridview on page load. My page does not have any upload control. It contains a textbox, button and the gridview. 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. ```