Questions tagged [fileresult]
74 questions
3
votes
2 answers
Show or Download File Correctly in ASP.NET MVC3 When File Type Isn't Text or Picture
This is My Action:
public FileResult ShowFile(long Id) {
DAL.Files.File file = new DAL.Files.FileAccess().GetById(Id);
return File(file.Content, file.FileType);
}
GetById method return a file from SQL DB, when the file type is text or…

Saeid
- 13,224
- 32
- 107
- 173
3
votes
2 answers
Is it possible to detect whether file actually downloaded
Suppose I have a controller action method that returns FileResult. Is it possible to detect whether file was actually downloaded completely to the client?
public ActionResult GetFile(int id)
{
DownloadInfo data = provider.GetInfo(id);
…

Robert Koritnik
- 103,639
- 52
- 277
- 404
2
votes
0 answers
MVC3 FilePathResult and FileStreamResult Replicated Downloads
I was reading a great article here that covers the in's and out's of using ASP MVC for uploading/downloading files. I'll try to keep this short here goes.
My MVC3 app will be running in one place (houston) and its mission will be to allow our…

Bayrat
- 161
- 1
- 3
- 17
2
votes
1 answer
How to view PDF document in MVC and not download it directly?
I have a link on click on it an HTML page will be converted to PDF document then return this PDF file to the user.
HTML code:
ViewReceipt
Code…

Noor Allan
- 421
- 2
- 7
- 17
2
votes
1 answer
Outputing workbook create in NPOI library using custom FileResult
I created an ASP.NET Mvc custom FileResult that will export a workbook(.xlsx).
See the codes below:
public class TestData
{
public string StudentName { get; set; }
public string Course { get; set; }
}
public class ExcelResult :…

rpmansion
- 1,964
- 1
- 9
- 26
2
votes
1 answer
FileResult not returning proper file type and file name
I have an ASP.NET MVC application with an ActionResult called GenerateReport. I'm trying to return a byte array to save an Excel file. Here are snippets:
var contentType = "application/vnd.ms-excel";
var fileName = "Statistics.xlsx";
...
var…

The Vanilla Thrilla
- 1,915
- 10
- 30
- 49
2
votes
2 answers
ASP.NET MVC 3 File download: Not Working in IE8
I have the Download that simply serves a static zip file from the local file system that works in Chrome and Firefox, but not in IE8.
The website is running on localhost with SSL, but I am getting the following error message in IE.
Unable to…

Abe
- 6,386
- 12
- 46
- 75
1
vote
3 answers
My Asp.NET HttpGet action (that return a FileResult) is only called once in the src of a object tag after a jquery post
I have a tag object that is loaded dinamically by javascript. This tag is loaded after a jquery post:
$.post('@Url.Action("ShowCredential", "ManageCredentials")',
$(form).serialize(), function(url) {
…

Vinicius Ottoni
- 4,631
- 9
- 42
- 64
1
vote
2 answers
how to check the file result is null within the mvc view
I have a controller method as below to send an image to a MVC view to display
public FileResult ShowImage(GuidID)
{
DataServiceClient client = new DataServiceClient ();
AdviserImage result;
result = client.GetAdviserImage(ID);
return…

5Series
- 13
- 1
- 3
1
vote
0 answers
How to grab a file and have it download on to the users computer that's not in wwwroot in c#?
So I have this function that's downloads a file from a specific path and the path is in a complete different folder path than the wwwroot. The folder is in a shared network folder. Nothing is downloading when it returns but i get no errors and it…

user17047507
- 11
- 2
1
vote
1 answer
Problem with download file with ajax call in asp.net core
I have some files in my wwwroot folder.
I want to write a code that user click on input button and download file that he wants.
So filename is unknown until user select his file.
I wrote this code:
Profile Controller:
public async…

NedaM
- 87
- 3
- 10
1
vote
1 answer
How to provide a friendly name to a File in ASP.NET Core without forcing the file to be downloaded?
I have the following REST Endpoint defined in my ASP.NET Core 3.1 application:
[HttpGet("files/{id}")]
[ProducesResponseType(typeof(FileContentResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public…

michael
- 787
- 2
- 6
- 12
1
vote
1 answer
FileResult content-length mismatch
Hi im using the code in this blogpost :
https://blog.stephencleary.com/2016/11/streaming-zip-on-aspnet-core.html
In order to stream a zip file with .Net core. I made it work but since i did not add the content-length header in the response when i…

Francis Groleau
- 344
- 4
- 14
1
vote
1 answer
Redirect To Action MVC convert to FILE RESULT
This is my code for Download a File in my MVC App. Im having a weird error and I cant a way to put it right. The error is >
Cannot implicitly convert type 'System.Web.Mvc.RedirectToRouteResult' to 'System.Web.Mvc.FileResult'
What I want with this…

Agar
- 13
- 2
- 11
1
vote
1 answer
MVC controller, get a file from WebAPI and return as FileResult
My controller needs to call a WebAPI method which will return an HttpResponseMessage object with a pdf file in the Content. I need to return this file immediately as a FileResult object from the the controller.
I was experimenting with a number of…

elector
- 1,327
- 4
- 26
- 43