[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Pivot Grid
   Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Collapse]File Management
   [Expand]File Manager
   [Collapse]File Upload
     File Processing Approaches
    [Expand]Visual Elements
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Extensions
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

File Processing Approaches

There are different ways to integrate the Upload Control into your ASP.NET MVC application depending on how you want to handle processing of uploaded files. This document describes the available approaches and provides information on scenarios for which these approaches are best suited.

The following approaches are available:

Expanded Custom Action

The Upload Control allows you to process uploaded files in a custom controller action. In the implementation of the custom action, you can access a collection of uploaded items using the static UploadControlExtension.GetUploadedFiles method.

Alternatively, a collection of uploaded files can be mapped to the action's parameter through model binding.

In the view code, specify your custom action as a callback handler using the UploadControlSettings.CallbackRouteValues property.

View code (ASPX):

View code (Razor):

This approach is best suited for applications requiring you to perform custom file processing involving the following tasks:

  • Custom file validation.
  • Custom processing of file contents.
  • Saving uploaded files to a custom storage.

Expanded Partial View

The Upload Control allows you to process uploaded files in an event handler within the view code. To use this approach, declare the Upload Control in a partial view. The code sample below demonstrates how to process uploaded files in the UploadControlSettings.FileUploadComplete event handler.

View code (ASPX):

View code (Razor):

In this case, the action handling callbacks just returns the partial view.

The described approach is preferable when there is little or no custom logic involved in file processing; the Upload Control uses the standard validation mechanism and files are saved to one of the standard storages.

Is this topic helpful?​​​​​​​