jquery文件上传插件大文件问题

时间:2015-03-27 11:11:37

标签: jquery asp.net-mvc jquery-ui jquery-plugins

我正在使用Asp.Net MVC 5和标准jquery plugin。我能够将文件大小上传24MB到MVC动作控制器。大于30MB的文件根本不会上传。 MVC FileUpload actionmethod上的断点永远不会被命中。是否需要设置一些配置?我四处搜索了一些文档,但无法找到任何文档。

这是我的web.config中的设置

 <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5" maxRequestLength="2147483647" executionTimeout="1600" requestLengthDiskThreshold="2147483647" />
  </system.web>

我添加了这个,现在允许我在组合文件中上传110MB。

 <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2147483647" />
      </requestFiltering>
    </security>
  </system.webServer>

1GB加文件仍然没有运气。在开发人员工具中,当我查看文件帖子时,我在网络部分得到500个内存不足错误。如何在IIS Express中调整内存或者这是本地桌面问题?

2 个答案:

答案 0 :(得分:0)

不是您的客户端代码阻止您的断点被击中,它是服务器拒绝POST请求,其中包含超过服务器上指定的最大字节数的文件的数据。

您可以通过将以下内容添加到应用程序的web.config来指定允许的最大文件大小(以字节为单位):

<configuration>
  <system.web>
    <httpRuntime maxRequestLength="xxx" />
  </system.web>
</configuration>

答案 1 :(得分:0)

这似乎不是编码问题,但您可以在一次调用中传输多少JSON数据。 如果您只想在web.config

中将其更新为最大长度,请查看this答案
<configuration> 
   <system.web.extensions>
       <scripting>
           <webServices>
               <jsonSerialization maxJsonLength="2147483647"/>
           </webServices>
       </scripting>
   </system.web.extensions>
</configuration> 

您也可以在代码中执行this。看看这个答案。

protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior) 
{ 
  return new JsonResult() { 
    Data = data, 
    ContentType = contentType, 
    ContentEncoding = contentEncoding, 
    JsonRequestBehavior = behavior, 
    MaxJsonLength = Int32.MaxValue 
  }; 
}