HTTP Error 404.13 - Not Found, when uploading big

2019-04-15 14:19发布

问题:

I want my web application to upload big zip file on the server. Here's my code logique :

@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>
}

In back hand c# code :

  [HttpPost]

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

The C# function is not reached... before it even enters the function i have :

HTTP Error 404.13 - Not Found

So i read this :

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

And it makes me feel like no one really knows the answer. Because in my case i'm sure it is related to MVC web.Config.

I added a bunch of <httpRuntime targetFramework="4.5.2" maxRequestLength="102400" executionTimeout="6000" /> in every pieces of config i could find... but no succes yet.

回答1:

You will also need to add this for IIS7+

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