最大请求长度超出异常

zSy*_*sis 19 exception asp.net-2.0

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

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



--------------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

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

<httpRuntime executionTimeout="800" maxRequestLength="51200" />
Run Code Online (Sandbox Code Playgroud)

任何方向都会非常有帮助.

com*_*ech 1

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

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

默认值为 30MB,但可以根据您的环境进行不同的设置。

web.config 条目将类似于:

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="1550000000" maxQueryString="16384" />
    <fileExtensions>
      <add fileExtension="." allowed="true" />
    </fileExtensions>
  </requestFiltering>
</security>
Run Code Online (Sandbox Code Playgroud)