I have a Action in controller as
public ActionResult Download()
{
return File(FileStream, "application/octet-stream", fileName);
}
If I want to use FilePathresult as:
public FilePathResult Download()
{
return File(FileStream, "application/octet-stream", fileName);
}
can I call the Download() on click of a button like this
@Html.ActionLink("FileDownload", "Download", new { file = item.FileName, GuID = item.DocumentGuID }) /text).Width(10);
Also is the implementation of Download() is correct in the second instance i.e.,in
public FilePathResult Download()
?
Your
ActionLinkdefines parameters that you want to pass so you will need to add those to your actionI’m not sure what
/text.Width(10);is doing there but a properly formedActionLinkwith parameters also must define the Html Attributes as the last parameter, just pass innull.Here is an example of a properly formed
ActionLink.You have a
fileand aGuIDparameter in your link, so add those to your action as parameters.Give it a try and let us know what happens 🙂
Happy coding!