2016-06-14 52 views
1

我希望我的Web應用程序能夠在服務器上上傳大文件。這裏是我的代碼logique:HTTP錯誤404.13 - 未找到,在asp.net MVC中上傳大文件

@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有關。

我在每一個配置中添加了一堆<httpRuntime targetFramework="4.5.2" maxRequestLength="102400" executionTimeout="6000" />我可以找到...但沒有成功。

+1

你可能不得不做出一些改變以IIS本身。有關更多詳細信息,請參閱本文,具體取決於您的IIS版本:http://ajaxuploader.com/large-file-upload-iis-asp-net.htm。它沒有達到你的方法的原因是因爲IIS已經在控制器到達之前將你的請求過濾出來(請記住請求通過IIS到達你的應用程序)。確保篩選器允許超過默認限制。 – RizJa

+0

在我的問題中告訴你IIS是完美的,其他應用程序也可以做到這一點 –

+0

嘗試設置maxAllowedContentLength屬性。 層次結構是:system.webServer - > security - > requestFiltering - > requestLimits – RizJa

回答

3

您還需要添加此爲IIS7 +

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

Hu!它的工作......這是我得到的最快答案,謝謝......它說我只能在發佈問題後至少15分鐘接受答案 –

+1

這爲我解決了它。它或者沒有被陳述,或者我忽略了這個事實,即無論你喜不喜歡,這個默認都適用於本節。 – Mmm