Error The length of the query string for this request exceeds the configured maxQueryStringLength value [duplicate]

StackOverflow https://stackoverflow.com/questions/16195326

Question

Hi Im developing a web application its working fine but yesterday i had a problem when i click a link it gives error

 The length of the query string for this request exceeds the configured maxQueryStringLength value.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The length of the query string for this request exceeds the configured maxQueryStringLength value.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:


[HttpException (0x80004005): The length of the query string for this request exceeds the configured maxQueryStringLength value.]
   System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +9672501
   System.Web.PipelineStepManager.ValidateHelper(HttpContext context) +53

when i see the url it gives

http://www.mysitename.com/Teams/Gallery.aspx**?__EVENTTARGET=ctl00%24ContentPlaceHolder1%24rptWeeks%24ctl04%24lnk&__EVENTARGUMENT=&tbcGallery_ClientState={%22ActiveTabIndex%22%3A2%2C%22TabState%22%3A[true%2Ctrue%2Ctrue]}&__VIEWSTATE=%2FwEPDwUJNDYyMTAzODEzD2QWAmYPZBYCAgMPFgIeBVN0eWxlBRZiYWNrZ3JvdW5kLWNvbG9yOmdyYXk7FgICAQ9kFgICBQ9kFgICAQ9kFgJmD2QWCAIBD2QWAgICD2QWAgIFDxYCHgVjbGFzcwUGYWN0aXZlZAIHDxYCHgtfIUl0ZW1Db3VudAIHFg5mD2QWAgIBDw8WBB4PQ29tbWFuZEFyZ3VtZW50BQIxNR4EVGV4dAUYTWFsYTNpYm5hIFByZW1pZXIgTGVhZ3VlZGQCAQ9kFgICAQ8PFgQfAwUCMjcfBAUTTWFsYTNpYm5hIExlYWd1ZSBJSWRkAgIPZBYCAgEPDxYEHwMFAjMyHwQFEFphaW4gT3BlbiBMZWFndWVkZAIDD2QWAgIBDw8WBB8DBQI0Mh8EBRRaYWluIFVuZGVyIDE4IExlYWd1ZWRkAgQPZBYCAgEPDxYEHwMFAjQzHwQ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2FK9O%2Bxvyvd6m1rEnMKWo8zEV33E9GFKXkFjcWaCqaAgW2qiov5SRArqihOrSxEYbyJa3g5qQ2Jam7H6jdg0mtjuPgJaWULMB%2FbpCAdf7ktVQXjmrf1y9oq2oWS9acNO9Yc1W5i938A6IkJSOiBwkBn1OwaXcQXjo9pmSp7Z9xBfTzCWOjndtxqVe7P1g60B6H8GaVHt8JQ0P9q28BwvC9cHdFGTamhPR6aaQPzluOZwy2nH0kxwu%2FoUc0j2Hci7AEQbcGPc9OqBo573zFB6oeD6YmSEm3FzZAMGiuKPtJYMLpVWASUEThx6G7J4u8p1gB6XIwUD8ik6AU4%3D**

Im not giving any querystring, the code where error occurs is

<div class="row-fluid">
                        <div class="span4" style="margin-top: 40px;">
                            <div class="header">
                                <span style="padding-top: 10px; padding-left: 10px;">Leagues</span>
                            </div>
                            <div class="mainbody">
                                <asp:Repeater runat="server" ID="rptLeagues" ClientIDMode="Static" OnItemCommand="rptLeagues_ItemCommand">
                                    <ItemTemplate>
                                        <p>
                                            <asp:LinkButton ID="lnk" runat="server" CommandName="select" CommandArgument='<%# Eval("LeagueId") %>'
                                                Text='<%# Eval("LeagueName") %>'>  
                                            </asp:LinkButton><i class="pull-right" style="font-size: 15pt;">»</i></p>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>
                        </div>
                        <div class="span4" style="margin-top: 40px;">
                            <div class="header">
                                <span style="padding-top: 10px; padding-left: 10px;">Stages</span>
                            </div>
                            <div class="mainbody">
                                <asp:Repeater runat="server" ID="rptStages" ClientIDMode="Static" OnItemCommand="rptStages_ItemCommand">
                                    <ItemTemplate>
                                        <p>
                                            <asp:LinkButton ID="lnk" runat="server" CommandName="select" CommandArgument='<%# Eval("LeagueId") %>'
                                                Text='<%# Eval("LeagueName") %>'>  
                                            </asp:LinkButton><i class="pull-right" style="font-size: 15pt;">»</i></p>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>
                        </div>
                        <div class="span4" style="margin-top: 40px;">
                            <div class="header">
                                <span style="padding-top: 10px; padding-left: 10px;">Weeks</span>
                            </div>
                            <div class="mainbody">
                                <asp:Repeater runat="server" ID="rptWeeks" OnItemCommand="rptWeeks_ItemCommand">
                                    <ItemTemplate>
                                        <p>
                                            <asp:LinkButton ID="lnk" runat="server" CommandName="select" CommandArgument='<%# Eval("LeagueId") %>'
                                                Text='<%# Eval("LeagueName") %>'>  
                                            </asp:LinkButton><i class="pull-right" style="font-size: 15pt;">»</i></p>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>
                        </div>
                    </div>

cs code

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillLeagues();
        }
    }
    protected void rptLeagues_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "select")
            {
                FillStages();
                rptWeeks.DataSource = null;
                rptWeeks.DataBind();
                tbcGallery.Visible = true;
            }
        }
        catch (Exception ex)
        {
            Messagebox.SetPopup("Error Found", ex.Message);
        }
    }
    protected void rptStages_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "select")
            {
                FillWeeks(e.CommandArgument.ToInt32());
                tbcGallery.Visible = true;

            }
        }
        catch (Exception ex)
        {
            Messagebox.SetPopup("Error Found", ex.Message);
        }
    }
    protected void rptWeeks_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "select")
            {
                //FillMatches(e.CommandArgument.ToInt32());
                tbcGallery.Visible = true;
                LoadVideos();
                LoadPictures();

            }
        }
        catch (Exception ex)
        {
            Messagebox.SetPopup("Error Found", ex.Message);
        }
    }

as you can see i m not giving any querystring and how i prevent the querystring to autogenerate
im using asp dotnet4 Ajaxcontroltoolkit and using updatepanel. Any suggestions?????

<asp:UpdatePanel ID="AjaxPanel" UpdateMode="Conditional" ChildrenAsTriggers="true"
        runat="server">
Was it helpful?

Solution 2

After fighting for one whole day i randomly found a solution I changed

 <form id="form1" method="GET" runat="server">    

to

<form id="form1"  runat="server"> <!--(this solved my problem.) -->

I dont know why method="Get" generate long querystring (when i click any link in my page) which was giving error The length of the query string for this request exceeds the configured maxQueryStringLength value

OTHER TIPS

The query string you are passing in the url is longer than 2048 which is the default value for maxQueryStringLength. You have to set a bigger value in the Web.config file (maxQueryStringLength) for example : "<httpRuntime maxQueryStringLength="16384" />" Here's a link for more info

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top