Large Uploads in ASP.NETNew in V4 |
![]() |
FileUp's ISAPI filter is used under ASP.NET to overcome ASP.NET's inefficient memory utilization and to allow accurate progress indication. The ISAPI filter significantly improves the performance of very large uploads. With the filter, FileUp can upload up to 4 gigabytes. 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 sending it to ASP.NET.
For performance reasons, the ISAPI filter will not intercept all ASP.NET requests; only those for a file with the extension .uplx will be handled by the filter. Files with the extension .aspx will not be processed by the filter, and will be sent directly to ASP.NET. This prevents burdening the server with unnecessary use of the ISAPI filter. So, to use the filter, name your ASP scripts FileName.uplx.
| Note: | Under ASP.NET, FileUp's progress indicator is handled by the ISAPI filter. So, to display accurate progress indication, upload to a file with the .uplx extension. |
FileUp's automatic installation package will install the ISAPI filter in IIS, and the script mapping for the upl extension. You can re-install the filter manually (if, for example, you move FileUp to a different machine), as follows:
| Note: | FileUp's ISAPI filter must be installed at the machine level, not the Web site or Web application level. |
| Note: | If you are testing FileUp with a beta release of IIS 6.0 on
Windows .NET Server, the Web site must be
configured to run in IIS 5 mode. The filter cannot be installed properly if
the site is in IIS 6 mode. To run IIS 6 in IIS 5 mode:
|
For information on mapping the uplx extension, see Allowing ASP.NET to Process Files with the .uplx Extension.
The ISAPI filter caches request data before it is processed by ASP.NET. The location of the cache files can be configured in the Windows registry. By default, the cache location is the system's default directory for cached files, which is determined by the system environment variable TEMP. To set a different ISAPI filter temp directory:
| Note: | To change the system's default directory for cached files,
reset the TEMP environment variable, as follows:
|
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.NET page on the server. If you set UseMemory in the ASP.NET 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.NET response page.
*/
function startupload() {
document.theForm.action="formresp.uplx?usememory=true";
}
</script>
</HEAD>
<BODY>
...
<TABLE ALIGN=center width="550" border=0>
<FORM onSubmit="startupload();" name="theForm" ACTION="formresp.uplx"
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>
...
FileUp's ISAPI filter will intercept requests for .uplx files. FileUp's automatic installation adds the appropriate script map to IIS so that requests for .uplx files are handled by the filter and then forwarded to ASP.NET. If you reinstall FileUp manually (if, for example, you move FileUp to a different server), you will need to add the following IIS script map:
| Note: | In the Windows XP IIS console, the Web Sites and Default Web Site nodes have identical properties dialogs. The script maps can be installed in the Web Sites properties, but they will be ignored by IIS. The script maps must be installed from the Default Web Site node. |
OR
| Note: | Under ASP.NET, FileUp's progress indicator is handled by the ISAPI filter. So, to display accurate progress indication, upload to a file with the .uplx extension. |
The IIS parameter MaxClientRequestBuffer sets a maximum size for the first chunk of a request. The first chunk will usually contain only a request's line and 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:
In the .NET configuration file for your Web application - web.config or machine.config - there are several attributes that can affect the performance of large uploads. To set these attributes at the machine level, modify machine.config (located in C:\WINNT\Microsoft.NET\Framework\v1.0.3705\CONFIG). To set the attributes at the application level, modify your application's web.config file.
You will find the following values in the httpRuntime node of machine.config:
executionTimeoutmaxRequestLengthThe following attribute is in the processModel node of machine.config:
responseDeadlockInterval"Infinite" or a time in the
format HH:MM:SS.