Handle the server-side FileUploaded event on the next Web Forms postback.
Upload files first, then submit the page to process the uploaded GUIDs on the server.
Two things that trip people up: FileUploaded fires on the postback, not during the transfer — without a submit, your handler never runs and the temp copy is swept after 60 minutes. If your page has no submit flow of its own, set AutoPostBack="true" on the control and the page posts back automatically when the batch finishes, exactly like v4 did. And the destination you pass to CopyFile/MoveTo accepts ~/ app-relative paths (resolved against the site root) or absolute paths; a bare relative path is also anchored at the site root, never the worker process directory.
Drag & drop files here, or paste from clipboard
<%-- ASPX Markup --%>
<au:AjaxFileUpload ID="Uploader1" runat="server"
OnFileUploaded="Uploader1_FileUploaded"
ShowProgress="true" />
<%-- No submit flow on the page? Post back automatically when the
batch finishes (v4 behaviour) instead of adding a button: --%>
<au:AjaxFileUpload ID="Uploader2" runat="server"
AutoPostBack="true"
OnFileUploaded="Uploader1_FileUploaded" />
<asp:Button runat="server" Text="Process Uploaded Files"
OnClick="BtnProcess_Click" />
// Code-behind or <script runat="server">
protected void Uploader1_FileUploaded(object sender, FileUploadedEventArgs e)
{
var uploadService = new UploadService();
var targetFolder = Server.MapPath("~/App_Data/Processed");
var safeFileName = Path.GetFileName(e.FileName ?? string.Empty);
Directory.CreateDirectory(targetFolder);
var savedFileName = Guid.NewGuid().ToString("N")
+ Path.GetExtension(safeFileName);
uploadService.CopyFile(
e.FileGuid,
Path.Combine(targetFolder, savedFileName));
}
Try It
Upload one or more files, then click Process Uploaded Files to raise
FileUploaded during the page postback.