Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Maximum request length exceeded

Posted on 2006-03-23
5
Medium Priority
?
3,148 Views
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"
                    DataSourceID="SqlDataSource1">
                    <Columns>
                        <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" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>"
                    DeleteCommand="DELETE FROM [RM00101] WHERE [CUSTNMBR] = @CUSTNMBR" InsertCommand="INSERT INTO [RM00101] ([CUSTNMBR], [CUSTNAME], [CUSTCLAS]) VALUES (@CUSTNMBR, @CUSTNAME, @CUSTCLAS)"
                    SelectCommand="SELECT [CUSTNMBR], [CUSTNAME], [CUSTCLAS] FROM [RM00101] ORDER BY [CUSTCLAS], [CUSTNAME]"
                    UpdateCommand="UPDATE [RM00101] SET [CUSTNAME] = @CUSTNAME, [CUSTCLAS] = @CUSTCLAS WHERE [CUSTNMBR] = @CUSTNMBR">
                    <DeleteParameters>
                        <asp:Parameter Name="CUSTNMBR" Type="String" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="CUSTNAME" Type="String" />
                        <asp:Parameter Name="CUSTCLAS" Type="String" />
                        <asp:Parameter Name="CUSTNMBR" Type="String" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:Parameter Name="CUSTNMBR" Type="String" />
                        <asp:Parameter Name="CUSTNAME" Type="String" />
                        <asp:Parameter Name="CUSTCLAS" Type="String" />
                    </InsertParameters>
                </asp:SqlDataSource>



 


0
Comment
Question by:gogetsome
5 Comments
 
LVL 25

Expert Comment

by:nauman_ahmed
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.

-Nauman.
0
 
LVL 14

Accepted Solution

by:
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.
 http://www.motobit.com/help/asp-upload/pa84.htm
0
 
LVL 12

Expert Comment

by:AGBrown
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.

Andy
0
 

Author Comment

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

Expert Comment

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

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