locked
increase file upload size to 30 mb RRS feed

  • Question

  • User-1369888382 posted

    In my web.config,I have

    <httpRuntime executionTimeout="900" maxRequestLength="20000" requestValidationMode="2.0" />

     

    Now, I need to allow file upoads upto 30mb.What changes shall I make?

    If I am increasing maxRequestLength value do I need to increase executionTimeout value as well?

    Tuesday, September 23, 2014 8:50 AM

Answers

  • User281315223 posted

    If you are going to be working with files that are larger than the default of 4MB, you'll need to update the maxRequestLength within your web.config to handle files of that size. This can be handled within the <system.web> section of your web.config or the <system.webServer> section if you want to handle it at the IIS level (both are probably a good idea).

    It's important to know that maxAllowedContentLength is measured in bytes and maximumRequestLength is measured in kilobytes when settings these values so you'll need to adjust them accordingly if you plan on handling much larger files : 

    <configuration>
        <system.web>
            <!-- This will handle requests up to 30MB -->
            <httpRuntime maxRequestLength="30720" timeout="3600" />
        </system.web>
    </configuration>
    
    <!-- IIS Specific Targeting (noted by the system.webServer section) -->
    <system.webServer>
       <security>
          <requestFiltering>
             <!-- This will handle requests up to 30MB -->
             <requestLimits maxAllowedContentLength="31457280" />
          </requestFiltering>
       </security>
    </system.webServer>

    If you don't see these sections within your existing web.config file, you'll simply need to copy them in.

    If I am increasing maxRequestLength value do I need to increase executionTimeout value as well?

    You shouldn't need to, but if you start experiencing issues (relating to timing out), you might want to try adjusting it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 23, 2014 10:11 AM

All replies

  • User1508394307 posted

    The maximum request size maxRequestLength is in kilobytes. 1MB is 1024 KB so 30 MB is 30720.

    Tuesday, September 23, 2014 8:58 AM
  • User-1369888382 posted

    how about 'executionTimeout'.Do I need to increase that as well?

    Tuesday, September 23, 2014 8:59 AM
  • User-1806150748 posted

    If uploading process / or any other processing time / execution time takes time, you might need to increase that.

    Tuesday, September 23, 2014 9:01 AM
  • User-1716253493 posted
    You only need to change MaxRequestLength for file size. I Here information about ExecutionTimeout : http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.executiontimeout(v=vs.110).aspx
    Tuesday, September 23, 2014 9:03 AM
  • User1508394307 posted

    how about 'executionTimeout'.Do I need to increase that as well?

    I would suggest to remove that attribute or leave it unchanged until you don't have any issue with upload. Note, that if you would have a file exactly 30 or a little bit more than 30MB you might need to have bigger value for maxRequestLength. Simply test it.

    P.S.

    IIS7 has a built-in request scanning which imposes an upload file cap which defaults to 30MB. So, if you would need to have an upload of more than 30MB, check http://blog.twinharbor.com/2011/07/28/fixing-iis7-maximum-upload-size/ or http://weblogs.asp.net/jongalloway/large-file-uploads-in-asp-net 

    Tuesday, September 23, 2014 9:08 AM
  • User281315223 posted

    If you are going to be working with files that are larger than the default of 4MB, you'll need to update the maxRequestLength within your web.config to handle files of that size. This can be handled within the <system.web> section of your web.config or the <system.webServer> section if you want to handle it at the IIS level (both are probably a good idea).

    It's important to know that maxAllowedContentLength is measured in bytes and maximumRequestLength is measured in kilobytes when settings these values so you'll need to adjust them accordingly if you plan on handling much larger files : 

    <configuration>
        <system.web>
            <!-- This will handle requests up to 30MB -->
            <httpRuntime maxRequestLength="30720" timeout="3600" />
        </system.web>
    </configuration>
    
    <!-- IIS Specific Targeting (noted by the system.webServer section) -->
    <system.webServer>
       <security>
          <requestFiltering>
             <!-- This will handle requests up to 30MB -->
             <requestLimits maxAllowedContentLength="31457280" />
          </requestFiltering>
       </security>
    </system.webServer>

    If you don't see these sections within your existing web.config file, you'll simply need to copy them in.

    If I am increasing maxRequestLength value do I need to increase executionTimeout value as well?

    You shouldn't need to, but if you start experiencing issues (relating to timing out), you might want to try adjusting it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 23, 2014 10:11 AM
  • User-1369888382 posted


     

    with the config changes,i am able to upload 30 mb files in my development machine.

     

    But in the server,it fails wit ha 'HTTP 404' error.

    I am using uploadify to upload the files.Will it be causing issue?

    Tuesday, September 23, 2014 10:27 AM
  • User281315223 posted

    But in the server,it fails wit ha 'HTTP 404' error.

    Are you sure that you are uploading them to the appropriate location? A 404 Error means that a particular resource or location could not be found. You might want to double-check where you are attempting to upload the files to.

    Tuesday, September 23, 2014 10:33 AM
  • User-1369888382 posted

    but for files with less size,say 20MB,its uploading correctly.

    Tuesday, September 23, 2014 10:34 AM
  • User281315223 posted

    It sounds like the settings in place to handle your larger 20MB+ files isn't working properly. This could either be because the size is larger than expected (you might try increasing the properties mentioned above a bit more) or there could be another issue at hand related to those properties not being recognized. 

    Tuesday, September 23, 2014 10:41 AM
  • User1508394307 posted

    Did you read the above links regarding maxAllowedContentLength on IIS7?

    You need to add following

    <system.webserver>
       <security>
         <requestFiltering>
           <requestLimits maxAllowedContentLength="30000000" />
         </requestFiltering>
       </security>
     <system.webserver>

    Where 30000000 is a number of bytes (30 MB)

    P.S.

    30000000 is a default value. Set bigger limit, depends on your size...

    Hope this helps.

    Tuesday, September 23, 2014 10:45 AM
  • User-1369888382 posted

    How did you arrive at the value '31457280' for 30 MB?Can you please explain.

    Thursday, September 25, 2014 2:55 AM
  • User1508394307 posted

    1024x1024x30

    1Mb is 1024Kb each 1024bytes

    It's not that important to have 31457280 or 30000000. Even Microsoft set default value of 30000000

    Also that is a limit of a whole request not a single file which you want to upload and request will be always bigger because it includes form variables, view state, etc. So, if your requirement is to have a file of 30Mb then set limit bigger than 30, e.g. 30500000 and test if it works.

    Thursday, September 25, 2014 3:15 AM