Previously file was located in the app folder so that I had given file path in anchor tag.
Now this file will be placed in different folder in server. I need to download/open the file.
What i have tried is
@Html.ActionLink("MyFile.xls", "DownloadFile", "Home")
public FileResult Download()
{
byte[] fileBytes = System.IO.File.ReadAllBytes(@"\\ip-myserver-101\MyFolder\MyFile.xls");
string fileName = "MyFile.xls";
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
}
But it did not work. I got error message .
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.Requested URL: /Home/DownloadFile
Ramesh PalanivelPosted Oct 26, 2017, 10:50 AM
Nepethya RanaPosted Oct 26, 2017, 11:35 AM
Madhanmohan DevarajanPosted Oct 26, 2017, 10:58 AM
Step by Step instructions for creating the downloadable file link in MVC application is given in the below links. Hope it will be helpful for you.