Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Collapse]File Management
   [Expand]Product Information
   [Expand]File Manager
   [Collapse]File Upload
     ASPxUploadControl Overview
    [Collapse]Concepts (ASPxUploadControl)
      Upload Modes
      Allowed Content Types
      Uploading Large Files
      Multi-File Selection
      Appearance Customization
      Drag and Drop Support
      Page Life Cycle During File Upload
    [Expand]Visual Elements
  [Expand]Multi-Use Site Controls
  [Expand]Scheduler
  [Expand]HTML Editor
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gauges
  [Expand]Data Editors
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Uploading Large Files

This topic describes customization specifics related to uploading large files via ASPxUploadControl. The specific approach to customization depends on the upload mode defined for ASPxUploadControl via the ASPxUploadControl.UploadMode property. To learn more on upload mode selection, refer to the Upload Modes topic.

Expanded Using Standard Upload Mode

ASPxUploadControl works in Standard Upload Mode if its ASPxUploadControl.UploadMode property is set to UploadControlUploadMode.Standard, or if the ASPxUploadControl.UploadMode property is set to UploadControlUploadMode.Auto and neither Html5 nor Silverlight technology is available.

In this mode, you can configure ASPxUploadControl to upload large files as described in the following Microsoft topics: FileUpload Class: Memory Limitations and PRB: Cannot Upload Large Files When You Use the HtmlInputFile Server Control.

Configure the following options to support the upload of large files.

  • maxRequestLength - in the Web.Config file

    Modify the httpRuntime element's maxRequestLength configuration setting (whose default value is 4096 in kilobytes) to increase the Request length limit, so that it represents the largest uploaded file size allowed for your application. This specifies the total size of all files that are selected within an ASPxUploadControl and uploaded in a single request. If the total size of the uploaded file/files is larger than maxRequestLength, the upload is canceled and the following exception occurs: "The server encountered an internal unspecified error that prevented it from fulfilling the request."

  • maxAllowedContentLength (IIS7 specific) - in the Web.Config file

    For IIS7, in addition to maxRequestLength, customization of the requestLimits element's maxAllowedContentLength configuration setting is also required (its default value is 30000000, in bytes).

  • MaxFileSize - in ASPxUploadControl

    If you define file validation settings and specify the UploadControlValidationSettings.MaxFileSize property of ASPxUploadControl, ensure that the Request length limit defined by Web.Config options (maxRequestLength, maxAllowedContentLength) is not less than the MaxFileSize property value. By default, the value of MaxFileSize is 0, which means that ASPxUploadControl does not perform file size validation by itself.

Note that in Standard Upload Mode, the maximum file size that can be uploaded is approximately 1 GB (see the Cannot Upload Large Files... topic on the Microsoft Support website for more details). Additionally, ASPxUploadControl requires memory for upload progress visualization. Therefore the actual maximum size of a file that can be uploaded using ASPxUploadControl in Standard Upload Mode with upload progress visualization enabled (the ASPxUploadControl.ShowProgressPanel property is set to true) is approximately 2GB/3 = 633MB. In this case, if you try to upload a larger file, you will see the server-side System.OutOfMemoryException exception.

Expanded Using Advanced Upload Mode

ASPxUploadControl works in Advanced Upload Mode if its ASPxUploadControl.UploadMode property is set to UploadControlUploadMode.Advanced, or if the ASPxUploadControl.UploadMode property is set to UploadControlUploadMode.Auto and either Html5 or Silverlight technology is available.

This mode is more suitable for uploading large files, because a file is uploaded in small packets, and is not cached in its entirety in server memory. The available Advanced Upload Mode customization capabilities are listed below.

  • File Packet Size

    The size of packets is specified by the UploadAdvancedModeSettings.PacketSize property of ASPxUploadControl. Its default value is 200000 bytes. If the progress panel of ASPxUploadControl is enabled (via the ASPxUploadControl.ShowProgressPanel property), the upload progress indicator is updated after each file packet is uploaded.

    You can increase the packet size if large files (10 MB and larger) will be uploaded and a high-speed Internet connection is used (for instance, when using Intranet applications). Conversely, it is recommended that you decrease packet size when most files are small and there is limited bandwidth.

  • Temporary File Folder

    In Advanced Upload Mode, ASPxUploadControl saves each uploaded file into a temporary file, which has the .tmp extension, within a specific server folder. You can specify this folder by using the UploadAdvancedModeSettings.TemporaryFolder property (~\App_Data\UploadTemp\ by default). Ensure that the ASP.NET application has 'write' access to the folder on the server (you can find more information on granting 'write' access to a web application in the following topic section in MSDN: FileUpload Class: Security Considerations).

  • Access to Uploaded File

    After ASPxUploadControl has finished uploading a file into a temporary file, the file settings can be accessed through properties of the file-related UploadedFile object instance. You can obtain this object via the FileUploadCompleteEventArgs.UploadedFile property (when handling the ASPxUploadControl.FileUploadComplete event) or via the ASPxUploadControl.UploadedFiles property (when handling the ASPxUploadControl.FilesUploadComplete event).

    For large files, it is recommended that you access the uploaded file content using the UploadedFile.FileContent property of the UploadedFile, and not via UploadedFile.FileBytes - to avoid server memory overflow. When using UploadedFile.FileContent, file content is treated as a file stream that needs to be disposed. Thus, it is necessary to operate the uploaded file's stream within the using statement (Using statement in Visual Basic).

    The simplest way to save the uploaded file is to use the UploadedFile.SaveAs method.

How would you rate this topic?​​​​​​​