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

我怎么解决这个问题?


当前回答

这也困扰了我好几天。 我修改了网页。配置文件,但它没有工作。 原来有两个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。)

这里如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>

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

值得注意的是,您可能希望将此更改限制为您希望用于上传的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>

我必须编辑C:\Windows\System32\inetsrv\config\applicationHost。将<requestLimits maxAllowedContentLength="1073741824" />添加到…

<configuration>
    <system.webServer>
        <security>
            <requestFiltering>

部分。

根据这篇微软支持文章