We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

File Size for Uploads setting in IIS? [Answered]RSS

21 replies

Last post Apr 12, 2013 09:34 AM by PeterVerberne

  • File Size for Uploads setting in IIS?

    May 09, 2007 11:43 AM|joker77|LINK

    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?

  • Re: File Size for Uploads setting in IIS?

    May 09, 2007 09:53 PM|ganeshanekar|LINK

    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

    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
  • Re: File Size for Uploads setting in IIS?

    May 10, 2007 03:51 AM|joker77|LINK

    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?

  • Re: File Size for Uploads setting in IIS?

    May 10, 2007 04:01 AM|ganeshanekar|LINK

     

    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

    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
  • Re: File Size for Uploads setting in IIS?

    May 10, 2007 04:25 AM|joker77|LINK

    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.

     

     

  • Re: File Size for Uploads setting in IIS?

    May 10, 2007 05:34 AM|joker77|LINK

    ganeshanekar

     

    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???

  • Re: File Size for Uploads setting in IIS?

    May 10, 2007 01:14 PM|anilr|LINK

    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)

     

    Anil Ruia
    Software Design Engineer
    IIS Core Server
  • Re: File Size for Uploads setting in IIS?

    May 11, 2007 04:19 AM|joker77|LINK

    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

  • Re: File Size for Uploads setting in IIS?

    May 11, 2007 04:41 AM|joker77|LINK

    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

  • Re: File Size for Uploads setting in IIS?

    May 11, 2007 08:05 AM|anilr|LINK

    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.

    Anil Ruia
    Software Design Engineer
    IIS Core Server
  • Re: File Size for Uploads setting in IIS?

    Feb 11, 2009 10:59 AM|vinceprofessor|LINK

    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!

  • Re: File Size for Uploads setting in IIS?

    Nov 24, 2009 03:03 PM|birbilis|LINK

    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)

    Vista StartMenu Run

    George Birbilis <birbilis@kagi.com>
    Microsoft MVP J# 2004-2010
    Borland Spirit of Delphi 2001
    http://www.zoomicon.com
  • Re: File Size for Uploads setting in IIS?

    Nov 24, 2009 03:26 PM|birbilis|LINK

    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).

    IIS UploadReadAheadSize

    George Birbilis <birbilis@kagi.com>
    Microsoft MVP J# 2004-2010
    Borland Spirit of Delphi 2001
    http://www.zoomicon.com
  • Re: File Size for Uploads setting in IIS?

    Nov 24, 2009 03:49 PM|birbilis|LINK

    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

    IIS CMS requestLimits mojoPortal NeatUpload maxAllowedContentLength

    George Birbilis <birbilis@kagi.com>
    Microsoft MVP J# 2004-2010
    Borland Spirit of Delphi 2001
    http://www.zoomicon.com
  • Re: File Size for Uploads setting in IIS?

    Oct 05, 2010 09:35 AM|sekhar akiri|LINK

    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.
  • Re: File Size for Uploads setting in IIS?

    Dec 13, 2010 03:54 AM|puicy|LINK

    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

  • Re: File Size for Uploads setting in IIS?

    Jan 13, 2011 05:57 PM|cwmizner|LINK

    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...

    For better or worse, in Microsoft I trust.
  • Re: File Size for Uploads setting in IIS?

    Jan 13, 2011 06:16 PM|cwmizner|LINK

     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...

    For better or worse, in Microsoft I trust.
  • Re: File Size for Uploads setting in IIS?

    Nov 08, 2011 08:02 AM|Nyatchebe|LINK

    Hi,

    I am having the problem.

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

  • Re: File Size for Uploads setting in IIS?

    Nov 21, 2011 09:21 AM|mohandeval|LINK

    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)

    appCmd .net $_SERVER "IIS" X64 2008 R2 Error 413 on IIS 7.5 Win2k8R2 .Net 4.0 server

  • Re: File Size for Uploads setting in IIS?

    Nov 22, 2011 04:26 AM|qbernard|LINK

    What kind of error you hitting now? intermittently only? size ?
    Cheers,
    Bernard Cheah
  • Re: File Size for Uploads setting in IIS?

    Apr 12, 2013 09:34 AM|PeterVerberne|LINK

    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)