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

我怎么解决这个问题?


当前回答

如果你有一个请求到站点中的应用程序,确保你在根web.config中设置了maxRequestLength。应用程序web中的maxRequestLength。Config似乎被忽略了。

其他回答

在web中有一个元素。配置上传文件的最大大小:

<httpRuntime 
    maxRequestLength="1048576"
  />

我认为这里没有提到它,但为了让它工作,我必须在web.config中提供这两个值:

在包含

<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />

在system。webserver中

<security>
    <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
    </requestFiltering>
</security>

重要提示:这两个值必须匹配。在这种情况下,我的最大上传是1024兆字节。

maxAllowedContentLength有1073741824字节。

我知道这很明显,但很容易被忽视。

值得注意的是,您可能希望将此更改限制为您希望用于上传的URL,而不是整个网站。

<location path="Documents/Upload">
  <system.web>
    <!-- 50MB in kilobytes, default is 4096 or 4MB-->
    <httpRuntime maxRequestLength="51200" />
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <!-- 50MB in bytes, default is 30000000 or approx. 28.6102 Mb-->
        <requestLimits maxAllowedContentLength="52428800" /> 
      </requestFiltering>
    </security>
  </system.webServer>
</location>

这也困扰了我好几天。 我修改了网页。配置文件,但它没有工作。 原来有两个Web。配置文件在我的项目, 我应该修改ROOT目录下的那个,而不是其他的。 希望这对你有所帮助。

如果您使用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。)