ASP.NET Upload Control (WebForms & MVC) - Upload Large Files using less RAM! (available now in v2011.1)

Check out the upcoming feature of our ASP.NET Upload Control that lets your end-users upload very large files without having your web server use lots of memory (RAM). And there are other benefits too.

Watch my 'Upload Big Files' video to learn about the new feature in DXperience v2011 volume 1:

Video: ASP.NET Upload Large Files

ASP.NET WebForms & MVC!

First, you'll be happy to know that the new 'upload large files' feature will be supported by both of our ASP.NET Upload WebForms control and ASP.NET MVC Upload Extension!

New Property

A new property is being introduced for our ASP.NET Upload Control and MVC Upload Extension called UploadMode. And it has 2 modes that determine how the upload control will behave and render:

  • Standard - Current/old mode - the upload control will send a file in one request. For small files, this is fine but if the file is very large then it can stress your web server as it has to load the entire file in memory
  • Advanced - New mode - the upload control will send a file using small packets. This gives you a few benefits…

...Benefits? Yes there are some pluses to 'Advanced' mode and one small caveat.

Advanced Mode Benefits

There are major benefits that you get when using the new 'Advanced' mode for uploading:

1. Upload Large Files

Upload large (2 gigabyte) files without using a huge amount of memory on your web server because the 'Advanced' mode uploads the file in small packets. The default PackedSize is 200 kilobytes and it saves these bytes to a temporary folder on your server (default is "~\App_Data\UploadTemp\").

When the upload has finished, you can access this file using the file stream:

protected void ASPxUploadControl1_FileUploadComplete(object sender, FileUploadCompleteEventArgs e) { 
    using(Stream stream = e.UploadedFile.FileContent)  { 
        //stream.Read(...); 
    } 
}

Or save the file using the SaveAs method:

protected void ASPxUploadControl1_FileUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FileUploadCompleteEventArgs e) {
    // don’t use FileBytes with Large Files!
    // byte[] a = e.UploadedFile.FileBytes;
 
    string filePath = Server.MapPath("~/uploads/" + e.UploadedFile.FileName);
    e.UploadedFile.SaveAs(filePath);
    // DoProcessUploadedFile(filePath);
}

2. Client-side Validation

The new 'Advanced' mode will validate the file size and extension on the client-side without sending files to the web server. This prevents unnecessary traffic to the web server. And to ensure proper validation and give you extra protection, our ASP.NET upload control will also perform a server-side validation check once the file has passed client-side validation.

3. Progress Bar in Medium Trust

'Advanced' mode also allows you to display the file upload progress bar even in web environments that only allow medium-trust. Learn more about 'medium-trust' ASP.NET applications from this MSDN article. In general:

Medium trust will place a number of restrictions on an application, including limiting an application’s file access to within the virtual directory where the application lives. - K. Scott Allen

4. Prevent DoS Attacks

With the 'Advanced' mode, you also don't need to set a very large 'maxRequestLength' value in your web.config file. The 'maxRequestLength' property specifies the limit for the buffering threshold of the input stream. For example, this limit can be used to prevent denial of service (DoS) attacks that are caused by users who post large files to the server.

Silverlight Required

The small caveat to the new 'Advanced' mode is that it requires Silverlight (version 3 and above) to render the upload control. This will require your end-users to have the Microsoft Silverlight plugin installed in their browsers. And we still provide the 'Standard' mode which uses standard HTML.

We chose to use Silverlight so you can quickly deliver to you a robust, proven solution for uploading large files. And by using Silverlight in the 'Advanced' mode, you get more benefits.

Available Now In v2011 vol 1

The new 'Advanced' mode feature of our ASP.NET Upload WebForms control and MVC Extension is available now with the DXperience v2011 volume 1 release.

What do you think of the slick new features in our ASP.NET upload control? Drop me a line below with your thoughts. Thanks!

DXperience? What's That?

DXperience is the .NET developer's secret weapon. Get full access to a complete suite of professional components that let you instantly drop in new features, designer styles and fast performance for your applications. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

Follow MehulHarry on Twitter

12 comment(s)

Very nice feature. You should rename the Mode to : Standard and Silverlight Enhanced since that is a requirement

12 May, 2011

Great feature,

But I would agree with Denny on SL Mode.

Then Silverlight requirement will be implied.

12 May, 2011

Mehul, a few of my clients have asked for the ability to drag a file from windows explorer into an aspxuploadcontrol. Has this abilty ever been discussed with you guys? Thanks.

13 May, 2011

Luke and Paul,

Thanks!

We didn't want to call it 'Silverlight Advanced' because we may still improve this feature by using other technologies like html5, SL, or flash in the future. We'll use the one that gives you the most benefits. :)

13 May, 2011

Hi Paul,

I recommend creating a suggestion for that.

Also, this may help you but it's browser-specific so not the best sln, imo: www.devexpress.com/.../Q321619.aspx

Thanks.

13 May, 2011

Thanks for the quick reply. Since it can not be supported because of it being browser specific, can I suggest it be considered in the advanced mode that uses silverlight?

16 May, 2011

Paul,

We'll certainly consider it, thanks.

23 May, 2011

a nice feature would be "Auto" mode.... checks if silverlight is already installed, if it is, then does advanced, if not, falls back to standard. Or maybe there's already a way to do this in page_init/load?

18 July, 2011

In medium trust environment it gives following error

Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

8 December, 2011

Hi Mohammad,

Please contact our support team here about the issue:

www.devexpress.com/.../CreateIssue.aspx

Thanks.

8 December, 2011

Does this also support files of 10GB or more?   We are having to upload large video files to our webserver.

Thanks!

-ed

1 November, 2012

Charles,

Most browsers and web servers have a limitation of 2GBs. For large uploads, its probably better to use FTP.

forums.asp.net/.../1

forums.asp.net/.../2

1 November, 2012

Please login or register to post comments.