Thursday, December 11, 2014

Upload and Download File in MVC

Create a new project and follow the screen shots

Now Add one ActionResult named FileUploadAction as shown below

Add View for this ActionResult just by simply right click on ActionResult and select "Add View"

Now write the code in cshtml page as shown below

Now write the upload functionality, here the commented code is used if you want to save the file in local physical directory as a file

Also add one file result and write the code as shown below.This File result is used for downloading the uploaded file

Now execute the code and check the url as well