我可以使用其他参数增加MVC Controller Action的ASP.NET请求的maxRequestLength吗?

lod*_*ddn 6 asp.net asp.net-mvc file-upload web-config filesize

我可以使用其他参数增加MVC Controller Action的ASP.NET请求的maxRequestLength吗?

我有一个带有ActionResult的UploadController,看起来像这样.

  [HttpPost]
  public ActionResult VideoUpload(int memberId)
  {
    var status= _docRepo.SaveDocument(DocumentType.Video, Request.Files, memberId);
        return Json(new { success = true, status = status});
  }
Run Code Online (Sandbox Code Playgroud)

文件可能非常大,我在web.config中增加了maxRequestLenght并且可以上传文件,但我担心安全问题.所以我尝试了这个并且它不起作用:

 <location path="VideoUpload">
        <system.web>
            <httpRuntime maxRequestLength="1024000" executionTimeout="600" />
        </system.web>
        <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="1024000"/>
                </requestFiltering>
            </security>
        </system.webServer>
    </location>
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?(上传方法使用swfupload)

Her*_*key 1

MVC 控制器操作不使用locationWeb.config 的部分。请参阅此答案以获取更多信息您可以通过MaxRequestLength 属性以编程方式增加它。