最大请求长度超出异常

时间:2010-11-04 16:18:47

标签: exception asp.net-2.0

我正在尝试使用上传控件上传一个20兆字节的文件,它在visual studio的内置网络服务器上工作正常但是一旦我将它发布到生产服务器(我无法访问),我一直收到以下错误:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Maximum request length exceeded. 
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: Maximum request length exceeded.

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): Maximum request length exceeded.]
   System.Web.HttpRequest.GetEntireRawContent() +11140903
   System.Web.HttpRequest.GetMultipartContent() +72
   System.Web.HttpRequest.FillInFormCollection() +245
   System.Web.HttpRequest.get_Form() +119
   System.Web.HttpRequest.get_HasForm() +11072199
   System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +124
   System.Web.UI.Page.DeterminePostBackMode() +83
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +270



--------------------------------------------------------------------------------

我已将以下内容添加到我的system.web节点,所以我不知道真正的问题是什么。

<httpRuntime executionTimeout="800" maxRequestLength="51200" />

任何方向都非常有帮助。

2 个答案:

答案 0 :(得分:1)

虽然您有一个20Mb的文件,但页面上的编码或其他内容可能会导致超出您设置的50Mb限制。我建议加倍你当前的设置。

还有另一个可以发挥作用的web.config设置:安全请求过滤maxAllowedContentLength

默认为30MB,但可以在您的环境中以不同方式设置。

web.config条目将是:

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="1550000000" maxQueryString="16384" />
    <fileExtensions>
      <add fileExtension="." allowed="true" />
    </fileExtensions>
  </requestFiltering>
</security>

答案 1 :(得分:0)

如果无法更改配置文件,请尝试直接从IIS更新属性httpRuntime executionTimeout="9200" maxRequestLength="200000">

供参考: maxRequestLength

相关问题