AsyncFileUpload file size limit

2020-05-28 18:48发布

问题:

When I was using AsyncFileUpload to upload 100KB image, I got no error message., but image not uploaded. I can upload 75KB image succssfully. I am using IIS 6.0.

    <cc1:AsyncFileUpload ID="afuImg" Width="400px" runat="server" 
UploaderStyle="Traditional" ThrobberID="Throbber2"  
    OnClientUploadError="uploadErrorImg" 
    OnClientUploadStarted="StartUploadImg" 
    OnClientUploadComplete="UploadCompleteImg" />

<httpRuntime maxRequestLength = "1024000" 
executionTimeout="54000" 
enableHeaderChecking ="false" />

回答1:

You can upload files with a combined size of up to 2GB, but it requires some modifications in your application configuration files.

  • set maxRequestLength in httpRuntime to 1024000000 (2GB max, you've done this)
  • Specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET. The value of this setting is ignored in debug mode. The default in .NET Framework 2.0 is 110seconds. To enable large file uploads, which can take large periods of time, increase this property. See the following MSDN article: http://msdn2.microsoft.com/en-us/library/e1f13641.aspx.
  • Open the file C:\Windows\System32\inetsrv\config\applicationHost.config and find the line:

    <section name="requestFiltering" overrideModeDefault="Deny" />
    
  • Set the overrideModeDefault property to Allow.
  • The following attributes can be assigned in the element of the machine.config file. They must be set at the machine level, not the application level in web.config.
  • responseDeadlockInterval - Specifies the time interval, in the format HH:MM:SS, after which the process is restarted if there has not been a response during this interval. The default is 3 minutes. To allow very large uploads, you may have to increase this value.
  • responseRestartDeadlockInterval - Specifies the time, in the format HH:MM:SS, that must elapse after the last restart to cure a deadlock before the process is restarted to cure a deadlock again. To allow very large uploads, you may have to increase this value.
  • AspMaxRequestEntityAllowed - Sometimes when the application is hosted on Windows Server 2003, the above settings do not seem to have effect. In this case you must modify the IIS metadata file, particularly the AspMaxRequestEntityAllowed property. For more info see: http://www.telerik.com/support/kb/article/b454K-gth-b454T-cee.aspx

Finally Though I don't see it very often

  • If there is any third party network monitoring software you should ensure that it is properly configured to allow file uploads with the needed length and content.

Also there is another question on stackoverflow which goes into this How do I configure IIS to handle really large file uploads?

In the above question the answer https://stackoverflow.com/a/206796/728841 lists Urlscan being the problem it has it's own request entity length limit. The person was not aware that Urlscan was running on the server because it was a global ISAPI filter, not running on the individual website.

Note: to locate global ISAPI filters, right click on the Web Sites folder in IIS Admin and click Properties, then on the ISAPI Filters tab.



回答2:

When trying to upload files over 200KB on IIS 6 the file may never upload and you either get an error or are sent to a blank screen. By default Windows server limits file uploads to about 200KB in size. To overcome this limit you must edit the IIS metabase.xml file.

1.Before you can edit the metabase.xml file you must tell IIS to allow you to edit the file. In IIS, right click the name of the server and select properties. Check "Enable Direct Metabase Edit".

2.Find the metabase.xml file located in C:\windows\sytem32\inetserv and open the file in Notepad.

3.Search for AspMaxRequestEntityAllowed and increase the value. The default value is 204800 (200K). Setting the value to 1000000 will allow 1 MB file uploads.

4.You may now wish to uncheck the IIS property called "Enable Direct Metabase Edit".

To increase the file download size limit, repeat all steps above but in Step 3 find the parameter called AspBufferingLimit. The default download limit is 4MB.