【问题标题】:HTTP Error 404.13 - Not Found, when uploading big file in asp.net MVC在 asp.net MVC 中上传大文件时,HTTP 错误 404.13 - 未找到
【发布时间】:2016-06-14 23:48:18
【问题描述】:

我希望我的 Web 应用程序在服务器上上传大 zip 文件。这是我的代码逻辑:

@using (Html.BeginForm("AddApplication", "Admin", FormMethod.Post, new { enctype = "multipart/form-data", @class = "form-horizontal", role = "form" }))
{
    <div class="form-group">
        <span>PUT FILE HERE : <input style="min-width: 550px;" type="file" name="zippedApp" /></span>
    </div>
}

反手c#代码:

  [HttpPost]

  public ActionResult AddApplication( string description, HttpPostedFileBase zippedApp)
  {
     //code
  }

没有达到 C# 函数......甚至在它进入我拥有的函数之前:

HTTP 错误 404.13 - 未找到

所以我读到了这个:

IIS7 - Webrequest failing with a 404.13 when the size of the request params exceeds 30mb

这让我觉得没有人真正知道答案。因为就我而言,我确信它与 MVC web.Config 有关。

我在我能找到的每一个配置中都添加了一堆&lt;httpRuntime targetFramework="4.5.2" maxRequestLength="102400" executionTimeout="6000" /&gt;...但还没有成功。

【问题讨论】:

  • 您可能必须对 IIS 本身进行一些更改。请参阅本文了解更多详细信息,具体取决于您的 IIS 版本:ajaxuploader.com/large-file-upload-iis-asp-net.htm。它没有到达您的方法的原因是因为 IIS 甚至在到达控制器之前就已经过滤掉了您的请求(请记住,请求通过 IIS 才能到达您的应用程序)。确保过滤器允许超过默认限制。
  • 在我的问题中告诉你 IIS 是完美的,其他应用程序也能做到这一点
  • 尝试设置 maxAllowedContentLength 属性。 层次结构为:system.webServer -> security -> requestFiltering -> requestLimits

标签: c# asp.net-mvc file-upload web-config


【解决方案1】:

你还需要为 IIS7+ 添加这个

<system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="52428800" /> <!--50MB-->
     </requestFiltering>
    </security>   
</system.webServer>

【讨论】:

  • 胡!它正在工作......这是我得到的最快答案谢谢......它说我只能在发布问题后至少 15 分钟接受答案
  • 这为我解决了。要么没有说明,要么我忽略了这样一个事实,即无论您喜欢与否,默认值都将适用于本节!
猜你喜欢
  • 1970-01-01
  • 2018-03-12
  • 2016-12-03
  • 1970-01-01
  • 2010-10-16
  • 2012-12-18
  • 2014-08-06
  • 2010-11-05
  • 1970-01-01
相关资源
最近更新 更多