Large Uploads in ASP



FileUp's ISAPI Filter

FileUp's ISAPI filter significantly improves the performance of very large uploads. With the filter, FileUp can upload up to 4-GB. Note that most browsers support uploads of up to 2 GB; larger uploads must be generated by a client-side control that can handle very large transfers. The ISAPI filter intercepts an upload request, reads all the data, and writes it to a temp file chunk by chunk, before forwarding the request to ASP.

FileUp can handle large uploads in ASP well without the ISAPI filter, but you may see improved performance with the filter. You will find information about optimizing the server configuration for large uploads in Tailoring Your Installation.

For performance reasons the ISAPI filter will not intercept all ASP requests; only those for a file with the extension .upl will be handled by the filter. Files with the extension .asp will not be processed by the filter, and will be sent directly to ASP. This prevents burdening the server with unnecessary use of the ISAPI filter. So, to use the filter, name your ASP scripts FileName.upl.

For security reasons, FileUp's automatic installation package will not install the ISAPI filter in IIS, or the script mapping for the upl extension. For installation instructions, see Installing the ISAPI Filter, and Allowing ASP to Process Files with the .upl Extension.

The ISAPI filter caches request data before it is processed by ASP. The location of the cache files can be configured in the Windows registry. For details, see The ISAPI Filter Temp Directory.

Upload Size on the Client
While FileUp can process uploads of up to 4-GB, most browsers support uploads of up to 2-GB. Larger uploads must be generated by a client-side control that can handle very large transfers, such as SoftArtisans JFile , and SoftArtisans XFile .
The ISAPI Filter and IIS 6
The ISAPI filter cannot be used with IIS 6 running in native IIS 6 mode. The ISAPI filter can be used with IIS 6 running in IIS 5 mode (for manual installation insructions, see Installing the ISAPI Filter). (FileUp's ASP.NET interceptor - the HttpModule - can be used in IIS 6 running in native IIS 6 mode, but ASP Applications cannot load this type of module.)

Top


The ISAPI Filter and the UseMemory Property

FileUp's UseMemory property allows you to keep uploaded data in memory until it is saved. The ISAPI filter reads the whole upload request and writes it to temporary files before the request is processed by the ASP page on the server. If you set UseMemory in the ASP page, the property will have no effect because the page is processed after the ISAPI filter writes the temp files. To set UseMemory when using the ISAPI filter, include the property in the request query string.

The following lines are from a client-side upload script. The form's onSubmit event is set to trigger the startupload function. This function adds UseMemory=True to the query string so that the ISAPI filter receives this information and does not cache the request.

	<HTML>
	<HEAD>
	...
	<SCRIPT Language="JavaScript">
	/* 
	The startupload function adds UseMemory=True to the query string.  The 
	ISAPI filter will read the query string, and instead of creating 
	temporary files, will store the uploaded file(s) in memory until 
	submitting them to the ASP response page.
	*/
	function startupload() {
		document.theForm.action="formresp.upl?usememory=true";
		}
	</script>
	</HEAD>
	<BODY>
	...
	<TABLE ALIGN=center width="550" border=0>
	<FORM onSubmit="startupload();" name="theForm" ACTION="formresp.upl" 
	ENCTYPE="MULTIPART/FORM-DATA" METHOD="POST">
	<TR>
		<TD ALIGN="RIGHT" VALIGN="TOP">Enter Filename:</TD>
		<TD ALIGN="LEFT"><INPUT TYPE="FILE" NAME="myFile"><BR>
		<I>Click "Browse" to select a file to upload</I></TD>
	</TR>
	<TR>
		<TD ALIGN="RIGHT"> </TD>
		<TD ALIGN="LEFT"><INPUT TYPE="submit" NAME="SUB1" VALUE="Upload File"></TD>
	</TR>
	</TABLE>
	</FORM>
	...

Top


ScriptTimeout

ASP's ScriptTimeout property sets the length of time in seconds that ASP pages will allow for a script to execute. The default value of this property in IIS is 90 seconds. In a file upload, the ASP page must execute for the duration of the upload. If your user is transferring information over a slow line or is transferring a large quantity of information, it is easy to exceed this limit.

To increase the ASP ScriptTimeout in IIS:

  1. Right-click the application that will perform uploads, and select Properties.
  2. Select the Virtual Directory tab and click Configuration.
  3. Select App Options.
  4. In ASP Script Timeout, enter a value in seconds.

To increase the ASP ScriptTimeout in script, set the property Server.ScriptTimeout. For example:

	<% Server.ScriptTimeout = 300 %>

The FileUp registry key DynamicAdjustScriptTimeout allows you to ensure that large uploads will not be timed out. If this key is set to True, IIS's ScriptTimeout value will be increased until an upload is complete.

To enable DynamicAdjustScriptTimeout:

  1. Open the Start menu and select Run...


  2. Enter regedit and click Ok.


  3. Open the folder HKEY_LOCAL_MACHINE\SOFTWARE\Software Artisans\FileUp\Parameters.


  4. Double click DynamicAdjustScriptTimeout. An Edit DWORD Value dialog will open.


  5. In the Value Data field, enter 1.

Top


ConnectionTimeout

IIS's Connection Timeout property sets a time in seconds at which the server will disconnect an inactive connection. The default value is 900 seconds. To allow very large uploads to complete it may be necessary to increase this value. To reset Connection Timeout:

  1. In IIS, right-click Default Web Site and select Properties.


  2. Select the Web Site tab.


  3. In the Connection Timeout box, enter a new value.

Top


MaxClientRequestBuffer

The IIS parameter MaxClientRequestBuffer sets a maximum size for the first chunk of an HTTP request. The first chunk will usually contain only a request's header fields, which includes all data in a request that is not part of the request's entity body. The default value of MaxClientRequestBuffer is 128 KB.

FileUp's ISAPI filter creates a new request and sends the entire request to ASP or ASP.NET as one chunk. When an upload contains many files, the ISAPI filter request may exceed the default value of MaxClientRequestBuffer and IIS might reject the request. To prevent this, add a MaxClientRequestBuffer key to the registry and set it to an appropriate value. Many factors can affect the size of the ISAPI filter request, but it will usually be around 128 KB per 600 uploaded files. To add MaxClientRequestBuffer to the registry and set it to a new value:

  1. Open the Start menu and select Run...


  2. Enter regedit and click Ok.


  3. Open the folder HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\.


  4. From the Edit menu select New -> DWORD Value.


  5. Right-click the new key and rename it MaxClientRequestBuffer.


  6. Double-click MaxClientRequestBuffer An Edit DWORD Value dialog will open.


  7. Under Base select Decimal.


  8. In the Value Data field, enter a buffer size in kilobytes.

Top


Copyright © 2003 SoftArtisans, Inc. All rights reserved.