exception - 最大请求长度超出异常(exception)

标签 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



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


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

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


在这方面的任何方向将非常有帮助。

最佳答案

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

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

默认值为30MB,但可以在您的环境中进行其他设置。

web.config条目将类似于以下内容:

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

关于exception - 最大请求长度超出异常(exception),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4098769/

相关文章:

c++ - 不可移动类的对象不可抛出?

c# - 从 HttpResponseException 中提取 HttpError

c# - VS2010 单元测试 - 抛出的异常为空白

c# - 通过 Web 部署项目更改应用程序池

asp.net - 在 IIS/ASP.Net 的 .NET 1.1 应用程序中创建 .NET 3.0 子应用程序

html - 用户应该如何在 asp.net 2.0 中从我的网站向我发送邮件

c# - InvalidParameterException 或 IllegalArgumentException

javascript - JavaScript console.log/trace 等策略

vb.net - 如何将数据读取器转换为数据表

c# - 格式化数据集中的日期时间列