So I have a MVC ASP.NET project, on a view when a button is clicked it should ask the user to save/open the file. But what it does is it opens the file in the browser. The file is a csv file.
Here is the code for the view
@using (Html.BeginForm("Download", "Home", new { name = ViewBag.Downloadfilename }, FormMethod.Post))
{
<button type="submit">Button 1</button>
}
While the code for the controller is such
public ActionResult Download(string name)
{
//string file = @"c:\someFolder\foo.xlsx";
string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
string file = name;
return File(file, Path.GetFileName(file));
}
So anyone know how the controller can force the user to save the file instead of opening in browser. (using chrome).
Thanks