I am trying to show a downloadable link on my MVC application’s View using ActionLink:
<div>
<%= Html.ActionLink("Test","Download","Admin") %>
</div>
public ActionResult Download()
{
var cd = new System.Net.Mime.ContentDisposition
{
FileName = "Download Me",
Inline = false,
};
Response.AppendHeader("Content-Disposition", cd.ToString());
byte[] csvBytes = Encoding.ASCII.GetBytes("hello");
return File(csvBytes, "csv","DownloadMe.csv");
}
The link shows up on the UI but when I click on it, I get an “Endpoint not found” error.
I am new to MVC and trying this out for the first time. Can someone please help.
I think you have a few issues with the controller method:
FileResult, not anActionResult.text/csvrather than justcsv.