Search code examples
web-configrequestlimit

Web.config - use application requestLimits


I have a page where user can Upload file to the server. I specified the

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

in my Web.config but I still get an error that request is too big. I found one solution - change system file applicationHost.config. I set

<requestLimits maxAllowedContentLength="512000000">

and it solved my problem. But we can't modify this file on out Dev server. I found some solutions e.g. use

<clear/>

or

<remove name="..."> 

in my Web.config

    <security>
        <requestFiltering>
            <clear/>
            <requestLimits maxAllowedContentLength="512000"></requestLimits>
        </requestFiltering>
    </security>

but now I get

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Solution

  • I think you need to set

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

    instead. That's 2GB - which I think is the maximum.