Header add

In this article we will discuss how to upload large files in ASP .NET using Generic Handler. You may require in some scenario to upload large files into server. If you prefer the traditional way for upload it may not be uploaded. Using Generic Handler we can able to upload large files.

The File will be read using HTML5 FormData JavaScript object and will be uploaded to server in small chunks (blocks) with Progress Bar using Generic Handler using XmlHttpRequest (XHR) in ASP.Net.

Let's create an ASP .NET Web application.

Open VS ⇛ File ⇛ New project 

Choose as an Empty application:

Add a WebForm page named as "Default.aspx" to Right click on project add new item.

Add the HTML mark up in Default.aspx like below;


Code Snippet Explanation

The HTML Markup consists of a Form with an HTML FileUpload element and a Button. Below the Form there’s an HTML5 Progress element for displaying the progress of the uploading File.
The Upload Button has been assigned a jQuery Click event handler. When the Upload button is clicked, an AJAX call is made to the Generic Handler using jQuery. The data of the selected File is read into an HTML5 FormData JavaScript object and the File is uploaded using XmlHttpRequest (XHR). A Progress event handler is attached to the XmlHttpRequest (XHR), which displays the progress of the File being uploaded using the HTML5 Progress element. Finally, the received Name of the uploaded File is displayed in an HTML SPAN element.

Add the Generic Handler that process the request.


The uploaded File is read from the Request.Files collection and is saved to a Folder (Directory) on Server’s Disk. Then Name of the uploaded file is returned back to the Client in JSON format.


Increase the request length in web.config

Run the application and see the result.



</> Find the Source Code in Github.com/CoreProgramm/



    Summary
  In this tutorial we discussed how to Upload Large files in ASP .NET using Generic Handler. If have any question related to this topic then give your feedback.

Post a Comment

Previous Post Next Post