IIS7 File Upload Size Limits

Default , IIS , Web Servers Add comments

By default, IIS7 limits file upload to 30MB.  Oddly, it returns a 404 error if someone uploads something larger than 30MB.   The docs from Microsoft are a little confusing on this, so I thought I would try to clarify.

According to the following article, you can "Remove the maxAllowedContentLength property." from the applicationhost.config file in IIS7 to lift the 30MB limit.  However, in my case, this property was never in the file to begin with.

http://support.microsoft.com/kb/942074/

So, my assumption on this is that the 30MB limit is somewhere internal to IIS7.  The article also doesn't say where to ADD the entry requestLimits node if it isn't already there.

Luckily, there is an alternate solution that can be enabled at the site level rather than server-wide.

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

If you add the above code to the web.config file for your site, you can control the maximum upload size for your site.  In many cases, the system.webServer node will already be in the file, so just add the security node within that.

Note that the maxAllowedContentLength is in BYTES not kilobytes.

You may also need to restart your Web site (not the whole server) to enable the setting.

In case you are curious, why would I want people to upload files larger than 30MB?  We were working on a video conversion script that allows people to upload large MOV files and converts them to FLV.

34 responses to “IIS7 File Upload Size Limits”

  1. AgoMago Says:
    A simle solution....

    Open IIS 7 SnapIn
    Select the website you want enable to accept large file uploads.
    In the main window double click 'Request filtering'
    once the window is opened you may see on top a list of tabs eg: file name extensions, rules, hidden segments and so on...
    regardless the tab you select, in the main window rightclick and select "Edit Feature Settings" and modify the "Maximum allowed content length (bytes)"

    Now you can upload files larger than 30 MB ....
  2. Brian Says:
    Great solution to IIS7 File Upload size limits.
  3. MKT Says:
    very thanks....
  4. TKM Says:
    many helpings...
  5. Marvin Says:
    Thanks a million!

    Was battling with this configuration for the Coporate Content Management System.
  6. edison954 Says:
    thanks.

    With this solution,...
    I'm uploading larger file (150 Mb), what happend with the time for uploading larger files, it´s too longer..

    can i to reduce this time?

    Thanks
  7. saurabh Says:
    it works..thanks buddy
  8. WebDAV Says:
    Any chance to upload a file over 2Gb in one piece? I need to upload files of at least 10Gb, otherwise IIS is not an option for me. As far as I understand 2Gb is the IIS and ASP.NET limitation, is it fixed in IIS 8 / ASP.NET 4.5?
  9. Mike Sprague Says:
    @WebDAV - To my knowledge it is not possible to do this with IIS 7.5. It has a 2GB max limit. There is also something else working against you. Most browsers limit you to a 2GB upload size anyhow. So, even if IIS would let it through, you might not be able to upload anyhow.

    More info here: http://www.motobit.com/help/scptutl/pa98.htm
  10. MM Says:
    This fixed an upload problem for me. Thanks!
  11. WebDAV Says:
    @Mike Sprague - most browsers support uploads over 2Gb already. Try Google Chrome for example.
  12. iurgi Says:
    Thanks
  13. Havexes Says:
    Merci bien
    The web config solution made my day
  14. VJ Says:
    Thanks much...
    It really helped...

    Cheers
    VJ
  15. Vlad Says:
    For some reason the solution above does not help for files over 2GB. We are setting a value to max which is 3.99GB and is <requestLimits maxAllowedContentLength="4294967295"/>
    Any idea what else should we try?
  16. Mike Says:
    @Vlad - What browser are your users using? Not all browsers support over 2GB upload. It's a little outdated, but there is a chart on this page: http://www.motobit.com/help/ScptUtl/pa33.htm
  17. Vlad Says:
    Mike, says, I tried every browser: chrome, ie, mozilla!!! It goes for awhile and then boom, it stops.
  18. WebDAV Says:
    ASP.NET 4.0 does not support uploads over 2Gb. According to this post it is increased in ASP.NET 4.5: http://aspnet.uservoice.com/forums/41199-general/suggestions/2642879-maximum-upload-size-in-asp-net-is-2gb-increase-it?tracking_code=5805b1d13655be23d0395513447ba9f7


    Chrome supports uploads over 2Gb, I have tested it.
  19. Empellex Says:
    Interesting. Thanks for sharing and providing a practical example.
  20. ASB Says:
    Also see the following:

    http://www.webdavsystem.com/server/documentation/large_files_iis_asp_net


    -ASB: http://XeeMe.com/AndrewBaker
  21. NickP Says:
    I spent all day looking for a solution until I read this article. You explained it very well so thank you
  22. Engin Says:
    I got the result without any problem on IIS 8. Thank you.
  23. Bedd Says:
    This is a good article. I am running mojoportal lates edition in mendiumtrust web config. I still don't get the result on live server. Only capable for uploading image file under 40kb only. I also have set the time out limit to 3600. Everything works well on local. Is there anymore settings to be set for this purpose??? Any help would be appreciated. Thanks.
  24. Helio Elias Says:
    Work for me.

    thks.
  25. raul mauricio Says:
    Uploading my files the iis 7.5, my iis 7 freeze while loading file any idea?
  26. Srini Says:
    I am also having the same issue as Bedd.

    Bedd: Any luck with you?


    thanks.
  27. Tawarus Says:
    Thx a lot solution from AgoMago date post May 24, 2010 at 3:02 AM. For me and my AjaxExplorer works fine. Again thx.
  28. Ben Nadel Says:
    Awesome sauce! This worked like a charm!
  29. Rubén Lama Says:
    Awesome you help soo much!!! thanks a lot!!!!
  30. Chris Barber Says:
    Then the issue arises, if you have a lot of clients that run IIS 7 or 7.5, how do I script this so that I can update it through a process....ahhh....here is the VB script for it (it'll add the necessary lines to the web.config)...hope this comes out OK.

    '<---Universal Variables--->

    dim xmlDom
    dim appSettingsNode
    dim childNode

    '<---Main Program--->

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    If objFSO.FileExists("Q:\stw\web.config") Then
       set xmlDom = CreateObject("Microsoft.XMLDOM")
       xmlDom.async = false
       xmlDom.load("Q:\stw\web.config")
       Dim objCurrNode, objNewNode, objNewText
       makeSecurity()
       addData()
       xmlDom.Save("Q:\stw\web.config")
    Else
       Wscript.quit
    End If

    '<---Sub to Make Elements--->

    Sub makeSecurity()
       set appSettingsNode1 = xmlDom.documentElement.selectSingleNode("/configuration/system.webServer")
       set objNewNode = xmlDom.createElement("security")
       appSettingsNode1.appendChild objNewNode
       Set objNewNode2 = xmlDom.createElement("requestFiltering")
       objNewNode.appendChild objNewNode2
    End Sub

    '<---Sub to Add Node and Attributes--->'

    Sub addData()
       set appSettingsNode2 = xmlDom.documentElement.selectSingleNode("/configuration/system.webServer/security/requestFiltering")
       Set childNode = xmlDom.CreateNode(1, "requestLimits", "")
       call childNode.setAttribute("maxAllowedContentLength", "524288000")
       appSettingsNode2.appendChild childNode
    End Sub
  31. Chris Barber Says:
    Then the issue arises, if you have a lot of clients that run IIS 7 or 7.5, how do I script this so that I can update it through a process....ahhh....here is the VB script for it (it'll add the necessary lines to the web.config)...hope this comes out OK.

    '<---Universal Variables--->

    dim xmlDom
    dim appSettingsNode
    dim childNode

    '<---Main Program--->

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    If objFSO.FileExists("Q:\stw\web.config") Then
       set xmlDom = CreateObject("Microsoft.XMLDOM")
       xmlDom.async = false
       xmlDom.load("Q:\stw\web.config")
       Dim objCurrNode, objNewNode, objNewText
       makeSecurity()
       addData()
       xmlDom.Save("Q:\stw\web.config")
    Else
       Wscript.quit
    End If

    '<---Sub to Make Elements--->

    Sub makeSecurity()
       set appSettingsNode1 = xmlDom.documentElement.selectSingleNode("/configuration/system.webServer")
       set objNewNode = xmlDom.createElement("security")
       appSettingsNode1.appendChild objNewNode
       Set objNewNode2 = xmlDom.createElement("requestFiltering")
       objNewNode.appendChild objNewNode2
    End Sub

    '<---Sub to Add Node and Attributes--->'

    Sub addData()
       set appSettingsNode2 = xmlDom.documentElement.selectSingleNode("/configuration/system.webServer/security/requestFiltering")
       Set childNode = xmlDom.CreateNode(1, "requestLimits", "")
       call childNode.setAttribute("maxAllowedContentLength", "524288000")
       appSettingsNode2.appendChild childNode
    End Sub
  32. Jegan Says:
    Works great.. Thanks
  33. wittawat Says:
    hello All

    I have my project about Download file from web server with ASP. I'm use IIS is Web server.

    if I'm specify

    Response.ContentType = "application/octet-stream"

    for download file type is ".txt" It Work But

    If if I'm specify = "application/octet-stream"

    for download file type is ".exe" size of file 856 KB.
    It not Work.

    I'm not Understand

    Help me please. Thank you
  34. Michael Sprague Says:
    wittawat - My guess here is that there are security restrictions on the ".exe" extension - see this article:
    http://mike-ward.net/blog/post/00631/how-to-configure-iis-7-to-allow-downloading-exe-files

    If that is not accurate, then you might want to try posting this question to an ASP developer forum or blog. I'm not familiar with ASP or how it works for sending files to the browser.

Leave a Reply

Leave this field empty:



Powered by Mango Blog. Design and Icons by N.Design Studio