I have a MVC-application. And I want to download a pdf.
This is a part of my view:
<p>
    <span class="label">Information:</span>
    @using (Html.BeginForm("DownloadFile")) { <input type="submit" value="Download"/> }
</p>
And this is a part of my controller:
private string FDir_AppData = "~/App_Data/";
public ActionResult DownloadFile()
{
    var sDocument = Server.MapPath(FDir_AppData + "MyFile.pdf");
    if (!sDocument.StartsWith(FDir_AppData))
    {
        // Ensure that we are serving file only inside the App_Data folder
        // and block requests outside like "../web.config"
        throw new HttpException(403, "Forbidden");
    }
    if (!System.IO.File.Exists(sDocument))
    {
        return HttpNotFound();
    }
    return File(sDocument, "application/pdf", Server.UrlEncode(sDocument));
}
How can I download the specific file?
 
     
     
    