Maximum request length exceeded

Posted on 2006-03-23
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

    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

    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 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

    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

    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

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Suggested Solutions

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now