加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-16 03:47:51 所属栏目:asp.Net 来源:网络整理
导读:我可以使用其他参数增加MVC Controller Action的ASP.NET请求的maxRequestLength吗? 我有一个带有ActionResult的UploadController,看起来像这样. [HttpPost] public ActionResult VideoUpload(int memberId) { var status= _docRepo.SaveDocument(DocumentTy
我可以使用其他参数增加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});
  }

文件可能非常大,我在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控制器操作不使用Web.config的location部分.请参见 this answer for more information.您可以通过 the MaxRequestLength property以编程方式增加它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读