Large Uploads in IIS 6 and 7



IIS 6 and 7 present two obstacles to very large file transfers: inefficient memory utilization and a 4-GB request size limit. To overcome these problems in IIS 6 and 7, FileUpEE provides the HttpModule and supports chunked transfer-encoding.

The HttpModule

FileUpEE's HttpModule intercepts selected requests to overcome ASP.NET's inefficient memory utilization and to allow accurate progress indication. The HttpModule 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 HttpModule will not intercept all ASP.NET requests. It will intercept ASP.NET requests for files with the extension .uplx. 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 HttpModule. So, to use the HttpModule, name your ASP.NET scripts FileName.uplx.

With the FileUpEE registry key FilterAspDotNetFlagExtension, you can change the file extension used to signal the HttpModule in ASP.NET (.uplx) to a different extension of up to seven characters. By using a file extension other than .aspx you can hide your web server implementation (Windows/IIS) from potential hackers.

If you install the ASP.NET version of FileUpEE, the automatic installation package will install the HttpModule for FileUpEE's samples, and create the script mappings for the .uplx extension. See Installing the HttpModule for instructions on installing the HttpModule at the application level or in the Global Assembly Cache.

Unlimited Upload Size on the Client
While FileUpEE can process uploads of any size, 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 XFileEE.
The HttpModule and Progress Indication
Under ASP.NET, FileUpEE's progress indicator is handled by the HttpModule. So, to display accurate progress indication, upload to a file with the .uplx extension.

Chunked Transfer-Encoding

IIS 6 and 7 get the size of a request from the request's content-length header, and do not accept requests larger than 4-GB. By default, IIS 6 and 7 accept requests of no more than 1-MB. You can increase this value by resetting the IIS 6 or 7 property MaxRequestEntityAllowed , but the maximum value is 4-GB.

To overcome the request size limits imposed by IIS 6 and 7, FileUpEE supports chunked transfer-encoding. A chunked file transfer is sent as a series of chunks, each preceded by its own size indicator. A chunked transfer request does not include a content-length header for the whole request. Since IIS 6 and 7 reject a request because of the size of the request's content-length header, they find no reason to reject a request without a content-length header. With chunked-transfer encoding, no matter how large the upload, it will not be rejected by IIS 6 or 7.

To prevent misuse of chunked uploading, FileUpEE allows you to control the maximum allowable file transfer through the MaxKBytes and MaxKBytesToCancel properties.

Browsers do not support chunked transfer-encoding. To send a chunked upload from client to web server you must use SoftArtisans XFileEE. Chunked transfer-encoding is not supported by Microsoft ISA Server and Microsoft Proxy Server. If your requests must go through ISA Server or Proxy Server, you cannot use chunked-transfer encoding.

To enable uploads of more than 4-GB to IIS 6 (running in native IIS 6 mode) and 7, you must use chunked-transfer encoding.

To send a chunked upload from the client-side browser to the web server, set XFRequest.TransferEncoding to 1 in your client-side XFileEE code. Set TransferEncoding before calling Start.


<script type="text/javascript">
...
XFileEE.TransferEncoding = 1;
try
{
    XFileEE.Start;
    ...
}
...
</script>
<body>
    <!-- This OBJECT tag declares and loads the XFRequest object (the non-visual control of XFile) into the page.
    Change the CODEBASE attribute if you choose to deploy the SAXFileEE.cab from another location -->
    <object id="XFile" codebase="SAXFileEE.cab"
        classid="clsid:8B3512EF-4FF5-4aa4-9CDE-56BB03E04B9F">
</body>

To send a chunked upload from web server to file server, on the web server set FileUpEE.TransferEncoding to saChunked. Set TransferEncoding after setting TransferStage, and before ProcessRequest.


Set oFileUpEE = Server.CreateObject("SoftArtisans.FileUpEE") 
oFileUpEE.TransferStage = saWebServer 
oFileUpEE.TransferEncoding(saWebServer) = saChunked
... 
oFileUpEE.ProcessRequest Request, False, False

AspMaxRequestEntityAllowed Metabase Property

In IIS 6.0, Microsoft introduced a new metabase property setting, AspMaxRequestEntityAllowed, to help users secure their web servers more easily. AspMaxRequestEntityAllowed lets users specify the maximum number of bytes allowed in the entity body of an ASP request. Unfortunately, this setting interferes with large FileUpEE uploads with ASP. If this setting is too low, you can observe the temp files being created but never saved, or IIS could return a 403 error response.

Additionally, multiple file uploads may return no error, but instead any file sent after the AspMaxRequestEntityAllowed value is exceeded will not be saved. The temp files will be created in the Path directory for all files in the transfer, but they will not be saved in the destination directory.

Hence, if you are performing large FileUpEE uploads in ASP on a server running IIS 6, you will need to edit the Metabase.xml file for your IIS installation. You can find your Metabase.xml file at C:\Windows\System32\Inetsrv. Find the AspMaxRequestEntityAllowed node and change the setting to a value just large enough for your largest uploads in bytes. For instance, if you expect no uploads greater than 1 GB, you can set the value to 1073741824.

For more information on the AspMaxRequestEntityAllowed metabase property, please read this article at the Microsoft Windows Server 2003 TechCenter: AspMaxRequestLengthEntityAllowed Metabase Property (IIS 6.0)


Session State Considerations

When Session State is turned on, the page is serialized and the page is locked while the process finishes. During a large file transfer, this means that the user cannot take any other action on the page until the transfer is complete. If the page requires user action to be possible during a large transfer, the session state can be turned off in ASP by adding the statement <% EnableSessionState=False %> or turned to Read-Only in ASP.NET by adding the statement <%Page EnableSessionState=ReadOnly %> to the top of the page.


Top

Copyright © 2010 SoftArtisans, Inc. All rights reserved.