Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum request length exceeded - no file upload

I have googled this exception extensively, and all the discussions I've found (including those on this forum) seem to be related to file uploading and exceeding the allowed file size limit. In my case however, I am not uploading anything, it is a simple postback.

I have a gridview displaying the results of an SQL query. This works correctly and displays the data as expected. Also, on the page are a couple dropdowns used to filter the data via control parameters on the SQL data source. However, any postback created on the page cause the above exception.

I have tested the query and all the filter parameters work as expected. I have tested removing various controls and cannot determine a single cause or point of failure, as the error occurs regardless of how the postback is triggered.

Any suggestions appreciated.

like image 313
Hearth Avatar asked Oct 19 '25 15:10

Hearth


1 Answers

Possible duplicate of Maximum request length exceeded exception on postback ?

Most likely you have ViewState enabled for the GridView, and a large amount of data in the GridView. If you do not need to maintain view state on the grid between postbacks, then you can disable it for that control by setting EnableViewState="false" on the control.

When ViewState is enabled for an ASP.NET webpage, a hidden field is added to the page that contains an encoded string that details the state of each control on the page (except those that have ViewState disabled). When the page is posted to the server, that field goes with it. Unfortunately, some controls like the GridView can contain a very large amount of state information, and this can result in a very large amount of post data, which can be enough to exceed the limits set for your application. As mentioned below, the default limit is 4MB.

ViewState can be disabled for your entire application, or for specific controls. Alternatively, you can increase the maximum request size. Please refer to the referenced question for details on this.

like image 53
Peter Avatar answered Oct 21 '25 07:10

Peter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!