Click Here to Download UploadAndDownloadFileInMVC.zip Example.
In many software application uploading and downloading files are required. There are very easy way to upload and download file in ASP.Net MVC framework.
Here is step by step example of how to implement upload and download functionality in MVC.
In this example we will also demonstrate how to change encoding type of form, how to apply CSS class to "Button" and "ActionLink" control and also How to apply style attribute with value.
STEP 1 : Add Upload View
Here is HTML of Uplod view file.
In many software application uploading and downloading files are required. There are very easy way to upload and download file in ASP.Net MVC framework.
Here is step by step example of how to implement upload and download functionality in MVC.
In this example we will also demonstrate how to change encoding type of form, how to apply CSS class to "Button" and "ActionLink" control and also How to apply style attribute with value.
STEP 1 : Add Upload View
Here is HTML of Uplod view file.
@using (Html.BeginForm("Index", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
<fieldset>
<legend>Upload a file</legend>
@Html.Raw(ViewBag.Message)
<div class="editor-field">
@Html.TextBox("file", "", new { type = "file" })
</div>
<div class="editor-field">
<input type="submit" value="Upload File" class="button_example" />
</div>
@Html.ActionLink("Go To Download Page","Index","Download",null, new {@class = "button_example",style="float:right"})
</fieldset>
}