当我试图在我的网站上上传视频时,我得到错误的最大请求长度超过了。

我怎么解决这个问题?


当前回答

我可以添加到config web uncompiled

<system.web> 
  <httpRuntime maxRequestLength="1024" executionTimeout="3600" /> 
  <compilation debug="true"/> 
</system.web> 
<security> 
  <requestFiltering> 
    <requestLimits maxAllowedContentLength="1048576"/> 
  </requestFiltering> 
</security>

其他回答

默认情况下,最大请求大小为4MB (4096 KB)

这里解释一下。

上面的文章也解释了如何解决这个问题:)

我被我们的网绊倒了。配置文件有多个系统。web部分:当我添加< httpRuntime maxRequestLength="1048576" />到系统时,它工作了。Web部分的配置级别。

这里如ex.我采取1024 (1MB) maxAllowedContentLength(长度字节)应该与你的maxRequestLength(1048576字节= 1MB)相同。

<system.web>
   <httpRuntime maxRequestLength="1024" executionTimeout="3600" />
</system.web>

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

如果您使用IIS托管应用程序,则默认上载文件大小为4MB。要增加它,请在您的网页中使用下面的部分。配置-

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

对于IIS7及以上版本,您还需要添加下面的行:

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

注意:

maxRequestLength以千字节为单位 maxAllowedContentLength以字节为单位

这就是为什么这个配置示例中的值不同。(两者都相当于1gb。)

如果你不能更新配置文件,但是控制了处理文件上传的代码,请使用HttpContext.Current.Request.GetBufferlessInputStream(true)。

disableMaxRequestLength参数的true值告诉框架忽略配置的请求限制。

详情请访问https://msdn.microsoft.com/en-us/library/hh195568(v=vs.110).aspx