页面超过了最大请求长度问题
今天遇到了这样的事情,“页面超过了最大请求长度问题”
“/AppShop”应用程序中的服务器错误。
超过了最大请求长度。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Web.HttpException: 超过了最大请求长度。
源错误:
执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。
堆栈跟踪:
[HttpException (0x80004005): 超过了最大请求长度。]
System.Web.HttpRequest.GetEntireRawContent() +8766626
System.Web.HttpRequest.GetMultipartContent() +62
System.Web.HttpRequest.FillInFormCollection() +168
System.Web.HttpRequest.get_Form() +68
System.Web.HttpRequest.get_HasForm() +8722023
System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97
System.Web.UI.Page.DeterminePostBackMode() +63
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +133
问题:在百万行数据表中真分页查询,页面上有一DropDownList用来选择页码,达到十万个下拉项,viewstate=true。
在页面回传时,产生超过了最大请求长度的 问题
分析:这可能是由于viewstate包含数据量过大,引起回传request包含数据量过大。
解决方案:可以在webconfig文件中修改最大请求长度。
<configuration>
<system.web>
<httpRuntime maxRequestLength="10000" ......>
</system.web>
</configuration>
<system.web>
<httpRuntime maxRequestLength="10000" ......>
</system.web>
</configuration>
结果:先设为1000,不通过,设为10000后,通过
总结:或进行二级分页可能更好