我可以使用附加参数增加 MVC 控制器操作的 ASP.NET 请求的 maxRequestLength 吗?

2024-01-11

我可以使用附加参数增加 MVC 控制器操作的 ASP.NET 请求的 maxRequestLength 吗?

我有一个带有 ActionResult 的上传控制器,看起来像这样。

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

文件可能非常大,我在 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>

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


MVC 控制器操作不使用locationWeb.config 部分。看此答案以获取更多信息 https://stackoverflow.com/questions/2550522/web-config-asp-net-mvc-location-system-web-authorization-integrated-se。您可以通过编程方式增加它MaxRequestLength 属性 http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.maxrequestlength.aspx.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我可以使用附加参数增加 MVC 控制器操作的 ASP.NET 请求的 maxRequestLength 吗? 的相关文章

随机推荐