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
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]HTML Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Navigation and Layout Extensions
  [Collapse]File Management
   [Expand]File Manager
   [Collapse]File Upload
     Overview - UploadControl
     File Processing Approaches
    [Expand]Visual Elements
  [Expand]Multi-Use Site Extensions
  [Expand]Charts
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Tree List
  [Expand]Data Editor Extensions
  [Expand]Report Extensions
  [Expand]SpellChecker
 [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

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.

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