错误此请求的查询字符串的长度超过配置的maxQueryStringLength值

时间:2013-04-24 14:58:33

标签: asp.net c#-4.0 updatepanel querystringparameter

嗨,我正在开发一个Web应用程序,它的工作正常,但昨天我有一个问题,当我点击一个链接,它给出了错误

 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

当我看到它给出的网址时

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=%2FwEPDwUJNDYyMTAzODEzD2QWAmYPZBYCAgMPFgIeBVN0eWxlBRZiYWNrZ3JvdW5kLWNvbG9yOmdyYXk7FgICAQ9kFgICBQ9kFgICAQ9kFgJmD2QWCAIBD2QWAgICD2QWAgIFDxYCHgVjbGFzcwUGYWN0aXZlZAIHDxYCHgtfIUl0ZW1Db3VudAIHFg5mD2QWAgIBDw8WBB4PQ29tbWFuZEFyZ3VtZW50BQIxNR4EVGV4dAUYTWFsYTNpYm5hIFByZW1pZXIgTGVhZ3VlZGQCAQ9kFgICAQ8PFgQfAwUCMjcfBAUTTWFsYTNpYm5hIExlYWd1ZSBJSWRkAgIPZBYCAgEPDxYEHwMFAjMyHwQFEFphaW4gT3BlbiBMZWFndWVkZAIDD2QWAgIBDw8WBB8DBQI0Mh8EBRRaYWluIFVuZGVyIDE4IExlYWd1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xAkzBhdFYaprmaiJymxLDcxE8lkCGq8O%2FK9O%2Bxvyvd6m1rEnMKWo8zEV33E9GFKXkFjcWaCqaAgW2qiov5SRArqihOrSxEYbyJa3g5qQ2Jam7H6jdg0mtjuPgJaWULMB%2FbpCAdf7ktVQXjmrf1y9oq2oWS9acNO9Yc1W5i938A6IkJSOiBwkBn1OwaXcQXjo9pmSp7Z9xBfTzCWOjndtxqVe7P1g60B6H8GaVHt8JQ0P9q28BwvC9cHdFGTamhPR6aaQPzluOZwy2nH0kxwu%2FoUc0j2Hci7AEQbcGPc9OqBo573zFB6oeD6YmSEm3FzZAMGiuKPtJYMLpVWASUEThx6G7J4u8p1gB6XIwUD8ik6AU4%3D**

我没有给出任何查询字符串,发生错误的代码是

<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);
        }
    }

你可以看到我没有提供任何查询字符串以及我如何使用asp dotnet4 Ajaxcontroltoolkit和使用updatepanel阻止查询字符串自动生成。任何建议?????

<asp:UpdatePanel ID="AjaxPanel" UpdateMode="Conditional" ChildrenAsTriggers="true"
        runat="server">

2 个答案:

答案 0 :(得分:1)

您在url中传递的查询字符串长于2048,这是maxQueryStringLength的默认值。您必须在Web.config文件中设置更大的值(maxQueryStringLength) 例如:"<httpRuntime maxQueryStringLength="16384" />" 这是link以获取更多信息

答案 1 :(得分:0)

战斗了一整天后,我随机找到了一个我改变的解决方案

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

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

我不知道为什么method =“Get”会生成长查询字符串(当我点击页面中的任何链接时),这会产生错误此请求的查询字符串长度超过配置的maxQueryStringLength值