Reputation: 1060
I'm working on an MVC application and trying to link to an Excel file on a file share that our users can download. I thought I had it set up correctly, but when I download the file it comes back as type 'file'.
UI Code
@Html.ActionLink("Excel sheet", "Download", new { @class = "a" })
Controller Code
public FileResult Download()
{
var FilePath = CurrentSettings.FilePath + "Template Files\\Entry Template.xlsx";
return File(FilePath, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", "Specimen Template File");
}
and here's how it shows up in Windows Explorer.
Feel like this is something obvious, hoping someone else has run into this.
Upvotes: 0
Views: 2485
Reputation: 32694
The definition of the File
method you are using is:
FilePathResult File(string fileName, string contentType, string fileDownloadName)
As you can see, the last parameter is file download name. So you need to provide the name of the file, including the extension.
return File(FilePath,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",
"Specimen Template File.xlsx");
Upvotes: 1