Web Forms upload guides

Batch Upload Progress in ASP.NET Web Forms

A support ticket has two attachments, a 1 MB screenshot and a 99 MB recording. When the screenshot finishes and the recording is still waiting, the page should show one of two files complete and 1% of the bytes transferred. Averaging the two file percentages would show 50%.

Give waiting files a place in the total

Sum the sizes of all files still in the batch, including files waiting for a slot. For each active file, count its latest uploaded byte total once. A progress event describes the transfer so far, so adding each event to the previous one would count the same bytes repeatedly.

batchPercent = totalBytes > 0
        ? Math.round(100 * uploadedBytes / totalBytes)
        : 0;

Clamp each contribution to the file size. A multipart request can carry form fields and headers alongside the file. For a batch of empty files, use the number of acknowledged files to decide when the batch has finished.

Keep the bar and the completion count separate

A browser can finish sending bytes while the handler is still assembling chunks or writing the file. Show transfer progress on the bar and update the completed count when the handler acknowledges success. If saving the business record is another step, label that action separately.

Test changes during a transfer

Add a second, larger file while the first is uploading. The percentage can fall because the total grew. Pause the larger file and keep its transferred bytes in the total. Cancel it and remove its contribution from both sides of the calculation. A retry should replace the previous byte reading for that task.

Try two differently sized files in the overall progress demo. For a queue that waits for the user to approve the selection, see the manual upload example.