ASP.NET File Upload Progress - Optional settings


By default UploadProgressModule stores temporary information and saves the uploaded files (if required) in the system's temp folder. To change the location for the temporary files, add the following tag into the <appSettings> element of your application web.config file:

<add key="OboutInc.FileUpload.TempFolder" value="c:/temp" />

The value is the physical path to the folder where the temporary files will be saved. You should ensure that the ASPNET user (NetworkService in Windows Server 2003) has FullControl rights on this location.

Also you can use the relative path for this setting:

<add key="OboutInc.FileUpload.TempFolder" value="~/FileUploadProgress/temp_folder" />

The value here is the relative path from the root of Web application. It should always start with "~/".

By default UploadProgressModule maintains the information about uploading progress in a temporary disc file. It is necessary for Web Garden supporting, but it makes the uploading process a little slow. If you don't use Web Garden, you can prevent its supporting by adding the following tag into the <appSettings> element:

<add key="OboutInc.FileUpload.WebGarden" value="False" />

In this case the speed of uploading will be increased.

Some profit for the speed be increased you can get in 'playing' with the uploading page size and pooling period of UploadProgressModule.
By default the pooling period is 10ms, you can set another value between 0ms and 1000ms:

<add key="OboutInc.FileUpload.PoolingPeriod" value="0" />

By default the uploading page size is 4Kb, you can set another value between 1Kb and 16Kb:

<add key="OboutInc.FileUpload.PageSize" value="8" />

By default, when server-side exception occurs while HTTP request processing, the error page appears when client-side finished data transmitting.
There can be different reasons of server-side exceptions:
  • out-of-memory in server
  • incorrect path of temp folder in Web.config file
  • not enough space in temp folder
  • maxRequestLength value of <httpRuntime> element exceeded

You can change such behavior by adding the following tag into the <appSettings> element:

<add key="OboutInc.FileUpload.CancelOnServerException" value="True" />

In this case data transmitting will be terminated by client-side and no Error page appears (page will be refreshed).
Also you can intercept this client-side event, see Server side properties page.

The final result (in Web.config) can look like this:

<configuration>
    ...
    <appSettings>
        <add key="OboutInc.FileUpload.TempFolder" value="c:/temp" />
        <add key="OboutInc.FileUpload.WebGarden" value="False" />
        <!-- 'as usual' behavior -->
        <add key="OboutInc.FileUpload.CancelOnServerException" value="False" />
        ...
    </appSettings>
    ...
</configuration>