Link to home
Start Free TrialLog in
Avatar of gogetsome
gogetsomeFlag for United States of America

asked on

Maximum request length exceeded

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>



 


Avatar of nauman_ahmed
nauman_ahmed
Flag of United States of America image

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.
ASKER CERTIFIED SOLUTION
Avatar of jjardine
jjardine
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of gogetsome

ASKER

jjardine thanks for the info. Adding  <httpRuntime maxRequestLength="8192" /> to the web.config as stated in the article fixed the issue.
I hope your network is fast if your pages are that big ;-)