locked
File Size for Uploads setting in IIS? RRS feed

  • Question

  • User-614497913 posted

    Hi there,

    Think this is my first post so bear with me!

    I have Vista Business running IIS7, and on this a Web Site and also a Web Service. The Web Site uploads a file to the Web Service. When the file size goes over 20Mb, a 404 error gets returned (after about a second). In the web.config of both I have added an entry to allow for large files:

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

    Could you please tell me is there a setting in IIS which only allows files up to a certain size to be uploaded, or if there is a max http request length?

    Wednesday, May 9, 2007 11:43 AM

Answers

  • User511787461 posted

    You are probably hitting a new limit in request-filtering feature (replacement for url-scan) in IIS7.  Try to set this to see if it helps

    appcmd set config "My Site/MyApp" -section:requestFiltering -requestLimits.maxAllowedContentLength:104857600 -commitpath:apphost

    the default for this is 30000000 (slightly less than 30MB)

     

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Thursday, May 10, 2007 1:14 PM

All replies

  • User157784788 posted

    What programming logic you are implementing to upload files? 

    AFAIK, By default, IIS will pre-read up to 48k bytes, but it is configurable by the UploadReadAheadSize metabase setting.

    It is defined in IIS_Schema.xml.

    <attribute name="uploadReadAheadSize" type="uint" defaultValue="49152" validationType="integerRange" validationParameter="0,2147483647" />

    But Please do not edit IIS_Schema.xml, instead To add configuration sections to the schema,put them in .xml files similar to this one, in this directory. They will be picked up automatically at application pool startup.

    Try increasing UploadReadAheadSize to something like "200000000".

    HTH.

    ~ Ganesh

    Wednesday, May 9, 2007 9:53 PM
  • User-614497913 posted

    Thanks Ganesh

     In the Web Service, I have a web method defined which takes in the file in the form of a byte array. The web method opens a FileStream, and writes the byte array to disk. For files up to 20Mb in size, this is no problem. When the file size gets over 20Mb roughly, a 404 error is returned when trying to access that web method.

    I need to know if there is a specific setting in IIS that would produce this behaviour?

    Thursday, May 10, 2007 3:51 AM
  • User157784788 posted

     

    If you are implementing byte array then bumping up UploadReadAheadSize value should fix this issue.

    The same type of issue was documented in following KB for IIS 5.0/6.0 and AFAIK in IIS 7 this would be the same.
    http://support.microsoft.com/kb/810957/en-us

    HTH.

    ~ Ganesh

    Thursday, May 10, 2007 4:01 AM
  • User-614497913 posted

    Thanks Ganesh - I'll give this a try and let you know how I get on, although is a 404 error I'm getting rather than a 400 one.

     

     

    Thursday, May 10, 2007 4:25 AM
  • User-614497913 posted

     

    If you are implementing byte array then bumping up UploadReadAheadSize value should fix this issue.

    The same type of issue was documented in following KB for IIS 5.0/6.0 and AFAIK in IIS 7 this would be the same.
    http://support.microsoft.com/kb/810957/en-us

    HTH.

    ~ Ganesh

    Hi again Ganesh. First off - I can't find where to set the UploadReadAheadSize - the link on MSDN is not very helpful.

    I am a bit confused. The default setting for this is 48kb right? But when I'm uploading a file as a byte array, it's fine for files up to 20Mb. What should I set the UploadReadAheadSize value to, to allow for files up to 100Mb???

    Thursday, May 10, 2007 5:34 AM
  • User511787461 posted

    You are probably hitting a new limit in request-filtering feature (replacement for url-scan) in IIS7.  Try to set this to see if it helps

    appcmd set config "My Site/MyApp" -section:requestFiltering -requestLimits.maxAllowedContentLength:104857600 -commitpath:apphost

    the default for this is 30000000 (slightly less than 30MB)

     

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Thursday, May 10, 2007 1:14 PM
  • User-614497913 posted

    Hey anilr - thanks for your help!

    I'm new to IIS, so this command is all new to me! Do I just need to replace the "My site/MyApp" section with the name of my site and run it from a command line?

    Do you have another command for me to tell what the value is currently?

    Thanks

    Friday, May 11, 2007 4:19 AM
  • User-614497913 posted

    Thanks again Anil - this worked!

    Just in case anybody else is looking for it:

    To get to appcmd.exe

    Start->Run-> runas /user:Administrator cmd
    cd c:\Windows\systems32\inetsrv

    Then just type in Anil's command from above

    Friday, May 11, 2007 4:41 AM
  • User511787461 posted

    Instead of doing "runas /user:administrator ..." you can right click on the command prompt icon and choose "run as administrator" - the difference is that it will run it with your credentials but with admin privileges enabled.

    To get settings, you can do "appcmd list config "My Site/MyApp" -section:requestFiltering" - appcmd -? or appcmd config -? or appcmd list config  -? etc will give you lots of help about how to use the various appcmd commands.

    Friday, May 11, 2007 8:05 AM
  • User488544618 posted

    Where is start-run in Vista?

    I can't even find the comand prompt!! Help!!

    I also have the file size problem. It is limiting me to 30 Meg!

    Wednesday, February 11, 2009 10:59 AM
  • User1584788341 posted
    Can right click the start (round win logo) button in Vista and select Properties then click Customize... to enable the setting that shows the Run menu option. Not really needed though since you can type cmd directly at the search bar and press ENTER to open the command prompt (btw you can do the same at any windows explorer folder view window, by typing cmd at the address bar - that has the added benefit that it will open the command prompt, with the current path set to be that folder)
    Tuesday, November 24, 2009 3:03 PM
  • User1584788341 posted
    It's logical (from reading the rest of the thread) that this wasn't the solution. After all by reading the MS support URL above one should conclude I think that they have to lower the UploadReadAheadSize value, not increment it (although it could maybe affect performance in big requests).
    Tuesday, November 24, 2009 3:26 PM
  • User1584788341 posted
    MANY THANKS!!! The "appcmd" command suggested by the IIS team solved the issue for me too (using mojoPortal CMS with NeatUpload [with NeatUpload's useHttpModule option enabled as is the default and having set its maxRequestLength option to a big value]) the path is: %windir%\system32\inetsrv so open a windows explorer folder, copy paste the following path in the address bar, then press ENTER to go there, then write cmd in the address bar and press ENTER assuming you have turned off UAC (User Access Control) in Vista and are logged in as an administrator else write Command in Start menu's Search box and when it finds the "Command Prompt" app, right click its icon and select "Run as administrator". Then at the command prompt enter: cd "%windir%\system32\inetsrv" and press ENTER key Also if windows isn't at drive C: but say at drive D:, write at the command prompt D: and press ENTER to go to that drive to see your site names give the command: appcmd list site to see your app names give the command: appcmd list app
    Tuesday, November 24, 2009 3:49 PM
  • User904967965 posted
    thank you for your answer. i am also facing same problem. i dont have access to my website IIS server. so how can i set the below command "My Site/MyApp" -section:requestFiltering-requestLimits.maxAllowedContentLength:104857600 -commitpath:apphost once again thank you very much for your answer.
    Tuesday, October 5, 2010 9:35 AM
  • User-540917860 posted

    Hi all,

    May i know that with the results listed from the command [appcmd list app], there the websites listed are where the web site's name that i can put into the command suggested by Anilr  [appcmd set config "website's name/" -section:requestFiltering -requestLimits.maxAllowedContentLength:104857600 commitpath:apphost].

    Please let me know if I was wrong. Thanks

    Regards

    Monday, December 13, 2010 3:54 AM
  • User-771111087 posted

    so I have a site called 'mySite'

    if I run:

    appcmd list config "mySite"

    I get an error pointing to my web.config.

    my question now becomes, is there a line you can put in your web.config to overcome this about 30MB  iis7 file upload ceiling?

    specific info about my problem:

    I'm getting a "The request failed with HTTP status 403: Forbidden." error on uploading 'large' files (test file is about 25MB).

    I put in this code to verify my MaxRequestLength of 65535 (set in my web config):

              var config = WebConfigurationManager.OpenWebConfiguration("~");
              var section = config.GetSection("system.web/httpRuntime") as HttpRuntimeSection;
              if (section != null)
              {
                var maxFileSize = Math.Round(section.MaxRequestLength / 1024.0, 1);
                var message = string.Format("Make sure your file is under {0:0.#} MB.", maxFileSize);
              } 

     

    So it seems this 'other' iis7 ceiling is my issue?

    I don't want to just run the command without some more understanding and ideally would like to just put a line in my web.config...

    Thursday, January 13, 2011 5:57 PM
  • User-771111087 posted

     so i found this that can go in the web config:

     

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

     

    it got me past my 403, but on to a new problem...  we store files in a SQL dbase, so off to investigate size limits there...

    Thursday, January 13, 2011 6:16 PM
  • User-694057221 posted

    Hi,

    I am having the problem.

    My test file is 48 MB. I still get the file too large response. please, help.

    Tuesday, November 8, 2011 8:02 AM
  • User-594800262 posted
    The solution given by Anil Ruia, seems to have worked, but looks like still intermittently we are having issues, ours is a IIS 7.5 Win2k8 R2, on .net4.0 website, with SSL., Prior to having a SSL we never had seen this issue, but is convincing that with SSL, the maxrequest length is throttled by the server. Need any best answers for the above issue, the operation we are performing while getting this error is a mouse hover Tool Tip with a window loading all the information mouse hovering a data item. appcmd set config "My Site/MyApp" -section:requestFiltering -requestLimits.maxAllowedContentLength:104857600 -commitpath:apphost the default for this is 30000000 (slightly less than 30MB)
    Monday, November 21, 2011 9:21 AM
  • User989702501 posted
    What kind of error you hitting now? intermittently only? size ?
    Tuesday, November 22, 2011 4:26 AM
  • User-2100183491 posted

    Thanks ANILR,

    Your solution works just fine.

    You could also go to the IIS GUI, click your website, double-click on request filtering, and alter the maximum allowed content length under

    Edit Feature Settings in de Actions Window (right side of the screen)

     

    Friday, April 12, 2013 9:34 AM