1

I have a Datagrid in my asp.net Web Application, that displays about 10000 records with Paging. The Datagrid displays find but when I click on page "10" for example I get the error message as

Maximum Request Length Exceeded

I searched online for similar questions but most of the solutions are for people who are uploading files not for Datagrid paging problems.

I tried adding

<security>
    <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>

in my web.config, system.webserver section but I still got the same problem.

Nad
  • 4,605
  • 11
  • 71
  • 160
user4612290
  • 311
  • 4
  • 7
  • 18

2 Answers2

3

A postback sends back the Viewstate of every control. If you have a huge DataGrid like you do, then when the browser re-posts that to the server, this is why you are getting the exception.

Try setting 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. But, then you might end up with other problems.

The other alternative is that you increase the maxAllowedContentLength that I see you have already tried.

TheBoyan
  • 6,802
  • 3
  • 45
  • 61
  • Thank you for your answer, I'm only able to alter my web.config at the moment. I had to add this property in httpruntime – user4612290 Apr 27 '15 at 14:01
  • Worked for me, and it was the answer I was looking for. It didn't make sense why I should have to tweak the IIS settings, since I was updating a asp.net control, not a datasource, the data was the same in both versions. – IjonTichy Feb 17 '23 at 15:09
1

In such case, you need to check the complexity of the functionality which you are doing. In your case, you are displaying a large number of data's in your grid.

As mentioned here. If you are using IIS 7, you must need to add the below line of code in your web.config file as it allows to insert a large amount of data which is required in your case.

<system.webserver>
<security>
  <requestFiltering>
     <requestLimits maxAllowedContentLength="1073741824" />
  </requestFiltering>
</security>

Hope this makes a sense a bit on how to handle large complexity data. :)

Community
  • 1
  • 1
Nad
  • 4,605
  • 11
  • 71
  • 160
  • Thank you I tried adding this as I mentioned in my question, but it didn't work. I had to set it with "httpruntime" – user4612290 Apr 27 '15 at 14:01
  • try debugging your code and see where exactly it is giving error – Nad Apr 27 '15 at 14:02
  • Thank you for your help, I used the answer from this post http://stackoverflow.com/questions/3853767/maximum-request-length-exceeded, the following lines were missing: – user4612290 Apr 27 '15 at 14:09
  • @user4612290: Glad that helped, so you can mark my post as answer that took to that reference.!! – Nad Apr 27 '15 at 14:10