2014-06-09 38 views
0

我在Windows 7上用IIS創建了一個非常簡單的ASP.NET MVC 5.1應用程序。我有一個非常簡單的窗體和控制器。我知道ASP.NET中的默認請求限制是4MB。但是當我上傳大於4 MB的文件時。我的請求將永遠不會返回。在Chrome,Firefox和IE上測試。事實上,我的控制器突破點從未達到過。我認爲ASP.NET MVC異步內部錯誤。這裏是我的html表單,當ASP.NET MVC 5.1/IIS中的上傳請求大小大於4 MB時,請求永不返回?

@using (Html.BeginForm("Add", "Product", FormMethod.Post, new { enctype = "multipart/form-data" })) 
{ 
     <input type="file" id="files" name="files" placeholder="Title" accept="image/x-png, image/gif, image/jpeg" /> 
} 

public async Task<ActionResult> Add(IEnumerable<HttpPostedFileBase> files) 
{ 

更新:在Chrome我不斷地看到這一點。 enter image description here

回答

0

您需要在您的web配置中設置maxAllowedContentLength

這樣的:

<system.webServer> 
    <security> 
      <requestFiltering> 
      <requestLimits maxAllowedContentLength="900000000" /> 
      </requestFiltering> 
    </security> 
</system.webServer>