Learn how to a build a cloud-first strategyRegister Now


Maximum request length exceeded

Posted on 2006-03-23
Medium Priority
Last Modified: 2008-02-20
Hello, I have a simple gridview that I want to allow editing with. Very simple really. The data populates correctly, But when you click on the edit button you get the error below. What could be causing this? I've ton of these and have never seen this error.
Exception Details: System.Web.HttpException: Maximum request length exceeded.

Stack Trace:
[HttpException (0x80004005): Maximum request length exceeded.]
   System.Web.HttpRequest.GetEntireRawContent() +293
   System.Web.HttpRequest.FillInFormCollection() +173
   System.Web.HttpRequest.get_Form() +64
   System.Web.HttpRequest.get_HasForm() +79
   System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +63
   System.Web.UI.Page.DeterminePostBackMode() +134
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +251

Here is the code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CUSTNMBR"
                        <asp:CommandField ShowEditButton="True" />
                        <asp:BoundField DataField="CUSTNMBR" HeaderText="CUSTNMBR" ReadOnly="True" SortExpression="CUSTNMBR" />
                        <asp:BoundField DataField="CUSTNAME" HeaderText="CUSTNAME" SortExpression="CUSTNAME" />
                        <asp:BoundField DataField="CUSTCLAS" HeaderText="CUSTCLAS" SortExpression="CUSTCLAS" />
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>"
                    SelectCommand="SELECT [CUSTNMBR], [CUSTNAME], [CUSTCLAS] FROM [RM00101] ORDER BY [CUSTCLAS], [CUSTNAME]"
                    UpdateCommand="UPDATE [RM00101] SET [CUSTNAME] = @CUSTNAME, [CUSTCLAS] = @CUSTCLAS WHERE [CUSTNMBR] = @CUSTNMBR">
                        <asp:Parameter Name="CUSTNMBR" Type="String" />
                        <asp:Parameter Name="CUSTNAME" Type="String" />
                        <asp:Parameter Name="CUSTCLAS" Type="String" />
                        <asp:Parameter Name="CUSTNMBR" Type="String" />
                        <asp:Parameter Name="CUSTNMBR" Type="String" />
                        <asp:Parameter Name="CUSTNAME" Type="String" />
                        <asp:Parameter Name="CUSTCLAS" Type="String" />


Question by:gogetsome
LVL 25

Expert Comment

ID: 16271733
Looks like it is being caused by SQL Server: check the field length in SQL Table and the field length that is posted for insertion.

LVL 14

Accepted Solution

jjardine earned 2000 total points
ID: 16272075
I believe that the problem is in regards to how much data you are passing back up to the server when you click your edit button.   By default asp.net only allows up to 4MB of data to be passed up in a request.   Because of this, if your datagrid and all the data included with it is greater than that limit then it will throw this error.   Some pages will see this error if you have a lot of controls and use viewstate because the viewstate will be huge and will be posted back even if not using it.   Here is an article talking about the problem and how to solve it. The quickest thing to try is to update the webconfig to use a larger maxRequestLength value.   See the article for more detail on this.
LVL 12

Expert Comment

ID: 16272371
How big is your viewstate? Is that causing it? Use something like Fiddler or ieHttpHeaders to inspect the length of the request you are sending, as jjardine says, it is likely that it is over the limit ASP.NET allows, or the web server is restricted to.


Author Comment

ID: 16272541
jjardine thanks for the info. Adding  <httpRuntime maxRequestLength="8192" /> to the web.config as stated in the article fixed the issue.
LVL 12

Expert Comment

ID: 16272568
I hope your network is fast if your pages are that big ;-)

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month20 days, 20 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question