31

Recently I had to get an old ASP application working in IIS 7.5 on a W2K8 server. Almost everything works fine, except that I can't seem to get it to accept uploads larger than ~200kB. I did find a setting, that from what I can understand should to the trick, in the applicationHost.config, I set the max request size to 100 MB like this:

<location path="TheNameOfMySite">
    <system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="104857600" />
            </requestFiltering>
        </security>
    </system.webServer>
</location>

Unfortunately, this seems to do nothing at all, it still refuses to accept any files larger than about 200 KB, and in the log file it gives this error message:

ASP_0104_:_80004005|Operation_not_Allowed

Googling that points to increasing the maxAllowedContentLength as I have done above. So I'm fresh out of ideas, but confident that the clever stackoverflow crowd can solve this in less time than it took for me to write this question.

user692942
  • 16,398
  • 7
  • 76
  • 175
Johan Driessen
  • 841
  • 2
  • 8
  • 13
  • You were on the right track, changing `maxAllowedContentLength` affects all requests not just Classic ASP ones, but without also changing `maxRequestEntityAllowed` *(which by default is 200 KB)* you will still be presented with `ASP 0104 : 80004005 Operation Not Allowed`. See [this answer](http://stackoverflow.com/a/22386054/692942) for a breakdown of how to configure large uploads in Classic ASP. – user692942 Apr 03 '15 at 10:47

6 Answers6

36

The maxAllowedContentLength controls how much data is allowed to be sent in a response. However you want to control how much can be accepted in a request. This is handled by the maxRequestEntityAllowed attribute of the limits element in the asp section of the config file. An example might look like:-

<system.webServer>
  <asp>
     <cache diskTemplateCacheDirectory="%SystemDrive%\inetpub\temp\ASP Compiled Templates" />
     <limits scriptTimeout="00:02:00"
        queueConnectionTestTime="00:00:05"
        requestQueueMax="1000"
        maxRequestEntityAllowed="104857600"
        />
  </asp>

You can configure this in the IIS7 manager under the "Limit Properties" category in the property grid for the ASP feature. Alternatively you can use a command line:-

appcmd set config /section:asp /limits.maxRequestEntityAllowed:104857600

Note that extending this value increase the window for DOS attack where the attacker sends large content to the server so don't be tempted to extend this beyond what you really need.

David Aleu
  • 3,922
  • 3
  • 27
  • 48
AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
  • 1
    It seems my trust in the Stack Overflow crowd was not misplaced! This solved the problem, thanks a lot! It's strange though, you would think that the requestLimits setting would affect the request and not the response... – Johan Driessen Jan 03 '10 at 11:10
  • Cheers Anthony, had the same problem and this solved it for me too. – Rich Jan 19 '10 at 19:34
  • @Johan Driessen: stackoverflow - never misplace your trust in it! – CodingInCircles May 09 '11 at 11:47
  • Edited to change the config flag to: /limits.maxRequestEntityAllowed:104857600 – David Aleu Mar 01 '12 at 17:35
  • 1
    Finally, a command prompt command that works (with `%windir%\system32\inetsrv\appcmd`). Much appreciated. – James Jan 14 '14 at 21:28
  • @AnthonyWJones `maxAllowedContentLength` does not control how much data is allowed to be sent in the response, in fact it has nothing to with the response. It is used to control the maximum length of content in a request, in bytes. This is across the board not just ASP requests, by default it's 28 MB (approx.) which is sometimes why it goes unnoticed. Only becomes an issue when uploading large files that exceed this default threshold. – user692942 Apr 03 '15 at 10:42
6

First off @AnthonyWJones answer was very helpful but didn't solve my problem, in fact it's slightly inaccurate and for that reason I'm writing this.

Large uploads in IIS 6 was a doddle you had one configuration value to worry about

AspMaxRequestEntityAllowed

The AspMaxRequestEntityAllowed property specifies the maximum number of bytes allowed in the entity body of an ASP request. If a Content-Length header is present and specifies an amount of data greater than the value of AspMaxRequestEntityAllowed, IIS returns a 403 error response. This property is related in function to MaxRequestEntityAllowed, but is specific to ASP request. Whereas you might set the MaxRequestEntityAllowed property to 1 MB at the general World Wide Web Publishing Service (WWW Service) level, you may choose to set AspMaxRequestEntityAllowed to a lower value, if you know that your specific ASP applications handle a smaller amount of data.


With the introduction of IIS 7 and it's new hierarchical XML-based configuration system that uses *.config files it all got a bit more complicated.

There are now two settings you need to configure correctly before Large File Uploading will work as you expect and they both live in different areas of the configuration.

maxRequestEntityAllowed

 <configuration>
   <system.webServer>
     <asp>
       <limits maxRequestEntityAllowed="200000" />
     </asp>
   <system.webServer>
 <configuration>

The maxRequestEntityAllowed attribute specifies the maximum number of bytes allowed in the entity body of an ASP request. If a Content-Length header is present and specifies an amount of data greater than the value of maxRequestEntityAllowed, IIS returns an HTTP 403 error response.

IMPORTANT: Configuring the above setting will work up to a point as you will see from the default below but once you reach that default regardless of what maxRequestEntityAllowed is set to, the server will respond with HTTP 404 Not Found error response. This confused me at first because I thought it must be my code that was returning the 404 error response.

maxAllowedContentLength

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

Specifies the maximum length of content in a request, in bytes. The default value is 30000000, which is approximately 28.6MB.

This setting is extremely important as it defines the maximum number of bytes in an IIS Request (not an ASP Request like the previous configuration value) it has nothing to do with the content length of the response (as has previously been stated). Regardless of what maxRequestEntityAllowed (which is a specific setting) is set to, if maxAllowedContentLength is not set or you try to upload more then the default of 28 MB (approx.) you will get a HTTP 404 error response.

Links

Community
  • 1
  • 1
user692942
  • 16,398
  • 7
  • 76
  • 175
6

On Windows 2008 - Go into Administrative tools - server Manager - expand Roles - expand Webserver -click on IIS - and look for the web instance, for which you want to change the file size limit and then go into option “ASP” expand “Limit properties” and property you need to change is 'Maximum Request Entity Body Limit'. File Size is always in bytes so use any online calculator to calculate the conversion of bytes to KB or MB.

BlackICE
  • 8,816
  • 3
  • 53
  • 91
2

The solution accepted here didn't work for me. First, there wasn't the element specified in my config and I didn't want to screw up a config file.

I also tried @shoaib-suleman's solution and it didn't work either. Finally, I ran across the solution shown here and it worked.

  1. Open IIS 7 SnapIn

  2. Select the website you want enable to accept large file uploads.

  3. In the main window double click 'Request filtering'

  4. 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,right-click to display a pop-up context menu. Select "Edit Feature Settings" in the menu.

  5. On the form that pops up, modify the "Maximum allowed content length (bytes)"

Community
  • 1
  • 1
Jeff Reddy
  • 5,551
  • 9
  • 55
  • 88
  • See [this answer](http://stackoverflow.com/a/22386054/692942) for an explanation as to why that worked and common mistakes being made in IIS 7+. – user692942 Apr 03 '15 at 10:37
2

for those who cannot execute the appcmd command from CMD, you need to change path to C:\windows\system32\inetsrv since the command reside in that folder.

cybersans
  • 29
  • 1
2

Go in IIS, choose you site and expand it then click the ASP icon in right panel.

Open the Limits Properties icon, and change the value in the “Maximum Requesting Entity Body Limit” to a value larger than 200000 (200kb). 2000000 would be around 2mb, 20000000 would be 20mb. Set according to your need and apply. That’s it!

ENJOY..

Amit
  • 43
  • 5