TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nepethya Rana
NA
335
152k
How do I download file from the server in MVC
Oct 26 2017 10:23 AM
Previously file was located in the app folder so that I had given file path in anchor tag.
<div style="color:#413f5a;padding:10px">
<a href="/MyApplication/MyAppFolder/MyFile.xls">
<i class="glyphicon glyphicon-file" style="font-size:20px"></i>
<span style="font-size:15px;margin-left:8px">MyFile.xls</span>
</a>
</div>
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
Reply
Answers (
3
)
Showing data from a table depending on certain user,
i don't show data in crystal view report form crystal report