Maximum request length exceeded.

前端 未结 14 2760
臣服心动
臣服心动 2020-11-21 07:37

I am getting the error Maximum request length exceeded when I am trying to upload a video in my site.

How do I fix this?

相关标签:
14条回答
  • 2020-11-21 07:48

    I don't think it's been mentioned here, but to get this working, I had to supply both of these values in the web.config:

    In system.web

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

    And in system.webServer

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

    IMPORTANT : Both of these values must match. In this case, my max upload is 1024 megabytes.

    maxRequestLength has 1048576 KILOBYTES, and maxAllowedContentLength has 1073741824 BYTES.

    I know it's obvious, but it's easy to overlook.

    0 讨论(0)
  • 2020-11-21 07:48

    If you have a request going to an application in the site, make sure you set maxRequestLength in the root web.config. The maxRequestLength in the applications's web.config appears to be ignored.

    0 讨论(0)
  • 2020-11-21 07:54

    To summarize all the answers in a single place:

    <system.web>
      <httpRuntime targetFramework="4.5.2" maxRequestLength="1048576"/>
    </system.web>
    
    <system.webServer>
      <security>
        <requestFiltering>
          <requestLimits maxAllowedContentLength="1073741824" />
        </requestFiltering>
      </security>
    </system.webServer>
    

    Rules:

    • maxRequestLength (expressed in kb) value must match maxAllowedContentLength (expressed in bytes).
    • most of the time your system.web section may already contains an "httpRuntime". set your targetFramework to the version of your .net used.

    Notes:

    • default value for maxRequestLength is 4096 (4mb). max value is 2,147,483,647
    • default value for maxAllowedContentLength is 30,000,000 (around 30mb). max value is 4,294,967,295

    more info MSDN

    0 讨论(0)
  • 2020-11-21 07:55

    There's an element in web.config to configure the max size of the uploaded file:

    <httpRuntime 
        maxRequestLength="1048576"
      />
    
    0 讨论(0)
  • 2020-11-21 07:57

    I can add to config web uncompiled

    <system.web> 
      <httpRuntime maxRequestLength="1024" executionTimeout="3600" /> 
      <compilation debug="true"/> 
    </system.web> 
    <security> 
      <requestFiltering> 
        <requestLimits maxAllowedContentLength="1048576"/> 
      </requestFiltering> 
    </security>
    
    0 讨论(0)
  • 2020-11-21 07:58

    It bothered me for days too. I modified the Web.config file but it didn't work. It turned out that there are two Web.config file in my project, and I should modified the one in the ROOT directory, not the others. Hope this would be helpful.

    0 讨论(0)
提交回复
热议问题