I found this link. ASP.NET MVC download image rather than display in browser
I tried everything and my action method dumps the file into the view instead of downloading. I would like to be able to download the file separately. Thanks
if (extension.ToLower() == ".docx")
{ // Handle *.jpg and
contentType = "application/docx";
}
else if (extension.ToLower() == ".jpg")
{// Handle *.gif
contentType = "image/jpeg jpeg jpg jpe";
}
else if (extension.ToLower() == ".pdf")
{// Handle *.pdf
contentType = "application/pdf";
}
Response.ContentType = contentType; // "application/force-download";
Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName);
Response.WriteFile(FilePath );
Response.Flush();
Response.End();[![View after clicking download button][1]][1]