我可以使用其他参数来增加MVC Controller Action的ASP.NET请求的maxRequestLength吗? [英] Can I increase maxRequestLength of ASP.NET request for MVC Controller Action with additional parameters?

查看:263
本文介绍了我可以使用其他参数来增加MVC Controller Action的ASP.NET请求的maxRequestLength吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用其他参数来增加MVC Controller Action的ASP.NET请求的maxRequestLength吗?我有一个带有ActionResult的UploadController,看起来像这样。

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





这些文件可能非常大,我在web.config中增加了maxRequestLenght,可以上传文件,但即时通讯担心安全问题。所以我试了这个,不工作:

 < location path =VideoUpload> 
< system.web>
< httpRuntime maxRequestLength =1024000executionTimeout =600/>
< system.webServer>
<安全>
< requestFiltering>
< requestLimits maxAllowedContentLength =1024000/>
< / requestFiltering>
< / security>
< /system.webServer>
< / location>

有什么想法?
(上传方法是使用swfupload)

解决方案

MVC控制器操作不使用位置部分的Web.config。有关更多信息,请参见此答案。 。您可以通过 MaxRequestLength属性

Can I increase maxRequestLength of ASP.NET request for MVC Controller Action with additional parameters?

I have a UploadController with a ActionResult looking somthing like this.

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

The files can be very large, i have increaset maxRequestLenght in web.config and can upload the files, but im worried about the security issue. So i tried this and its not working:

 <location path="VideoUpload">
        <system.web>
            <httpRuntime maxRequestLength="1024000" executionTimeout="600" />
        </system.web>
        <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="1024000"/>
                </requestFiltering>
            </security>
        </system.webServer>
    </location>

Any ideas? (the upload method is using swfupload)

解决方案

MVC Controller Actions do not use the location section of the Web.config. See this answer for more information. You can increase it programmatically via the MaxRequestLength property.

这篇关于我可以使用其他参数来增加MVC Controller Action的ASP.NET请求的maxRequestLength吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆