Asp.net

超出最大請求長度。

  • October 4, 2010

當我嘗試在我的網站上上傳影片時,我 收到錯誤“超出最大請求長度”。

我該如何解決?

如果您使用 IIS 託管您的應用程序,則預設上傳文件大小為 4MB。要增加它,請在您的web.config-

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

對於 IIS7 及更高版本,您還需要添加以下行:

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

注意

  • maxRequestLength千字節為單位
  • maxAllowedContentLength字節為單位

這就是為什麼此配置範例中的值不同的原因。(兩者都相當於 1 GB。)

引用自:https://stackoverflow.com/questions/3853767