Hello Friends, In this tutorial, I am going to create an example for how to Upload File in ASP.NET MVC.


Upload File is an important task for every application. In this tutorial, I am going to create an example for Uploading File. The posted file is available as HTTPPostedFileBase.

Upload File

Upload File in ASP.NET MVC.

Step 1- Open visual studio and create an MVC4 application called UploadFileDemo,

Upload File

Step 2- Choose an empty template and Click OK. An empty solution will be completed.

Step 3- Right Click on the Controllers folder and Create a Controller called HomeController. A Controller with the following code will be created.

Step 4- Right Click on the Index action method and Add a View called Index.

Step 5- Write the following code into Index.cshtml.

Step 6- Right Click on the Solution Explorer and create a folder called Scripts.

Step 7- Add the following Scripts in the Scripts folder that we have created in Step 6.

  • jquery-1.7.1.min.js.
  • jquery.validate.min.js.
  • jquery.validate.unobtrusive.min.js.

Step 8- Right Click on the Scripts folder and Create a JavaScript file called App.Js. Write the following code in App.js.

Step 9- Now the complete code for the View would be.

Step 10-  Right Click on the Solution Explorer and create a folder Content.

Step 11- Goto HomeController and write the following method in HomeController.

Run the application and look at the output screen.

Upload File

You can download the complete Source Code for the application from here.


Hope you understand this tutorial about Uploading File in ASP.NET MVC. I will appreciate your feedback, comments and suggestions.

View More:

Thank You.

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, bool given in C:\inetpub\vhosts\debugonweb.com\httpdocs\wp-includes\wp-db.php on line 3353