Questions tagged [filestreamresult]
57 questions
33
votes
2 answers
With FileStreamResult, how is the MemoryStream closed?
The following code works, but I'm wondering if the MemoryStream created is closed properly. How should this be performed or does FileStreamResult handle it for me?
public FileStreamResult DownloadBudgetedRoleOpportunities(
Guid projectGuid,
…

kenny
- 21,522
- 8
- 49
- 87
26
votes
2 answers
ASP.NET MVC FileStreamResult not working as intended
I have the following code which I stripped out of any non-essential lines to leave the minimun reproducable case. What I expect is for it to return the image, but it doesn't. As far as I can see it returns an empty file:
public ActionResult…

Pablo Fernandez
- 279,434
- 135
- 377
- 622
15
votes
3 answers
ASP.NET MVC FileStreamResult, fileDownloadName is not used
The following returns a PDF which the browser tries to directly display inline. This works correctly. However, if I try to download the file, the download name is not "myPDF.pdf", but instead the ID in the route (myapp/controller/PDFGenerator/ID).…

user1620141
- 315
- 1
- 2
- 16
6
votes
1 answer
Get File Name From FileStreamResult When Using Ajax/Axios?
I have in my asp.net core api controller
return new FileStreamResult(excel, "application/ms-excel")
{
FileDownloadName = filename
};
I am doing an ajax request to get this file
var response = axios.get(
…

chobo2
- 83,322
- 195
- 530
- 832
5
votes
1 answer
Stream MP3 file MVC3
I am trying to stream a file using the audio HTML5 tag. I have put the Controller action to return a FileStream and attached it to the src for the audio. However, the content is not loading into the audio tag and doesn't play when I press the…

Clay Wright
- 75
- 1
- 5
5
votes
1 answer
Why is my File result filename corrupted IE9?
I'm trying to generate and return files for my users. Some file names contain unicode characters: aäa.pdf. When trying to download them in IE 9 the filename gets corrupted and the download appears like this:
In Chrome it works as expected.…

Joel Peltonen
- 13,025
- 6
- 64
- 100
4
votes
1 answer
Return a FileStreamResult if successful or View if unsuccessful
In MVC, is there a way to return a FileStreamResult if my query is successful, but if not, just return the View with an error in the ViewBag. Like so....
public FileStreamResult Submit()
{
string retVal;
try
{
…

Zach
- 640
- 1
- 6
- 16
4
votes
3 answers
asp.net mvc serving txt gets truncated
I'm trying to serve a txt file made from the database using an action. The action is the following:
public ActionResult ATxt()
{
var articulos = _articulosService.ObteTotsArticles();
return File(CatalegATxt.ATxt(articulos),…

Carles Company
- 7,118
- 5
- 49
- 75
3
votes
1 answer
How to redirect page after returning FileStreamResult in ASP.NET MVC
We have a reporting feature on our site that allows users to download PDF reports of various data. Some of the reports require parameters, and when this is the case we forward them to a parameter setting view after they choose a report.
After…

Daniel Caves
- 41
- 2
3
votes
0 answers
FileStreamResult in ASP.NET core of a large file ( > 2 GB) results in System.IO.IOException: Stream was too long
I am trying to send a large file using FileStreamResult -
return new UnbufferedFileStreamResult(new FileStream(apiResponse.url, FileMode.Open, FileAccess.Read), "text/csv") { FileDownloadName = new FileInfo(apiResponse.url).Name };
The…

tacos_tacos_tacos
- 10,277
- 11
- 73
- 126
3
votes
1 answer
Wrong encoding on JavaScript Blob when fetching file from server
Using a FileStreamResult from C# in a SPA website (.NET Core 2, SPA React template), I request a file from my endpoint, which triggers this response in C#:
var file = await _docService.GetFileAsync(token.UserName, instCode.Trim()
.ToUpper(),…

Thomas Darvik
- 748
- 7
- 22
3
votes
4 answers
ASP.NET MVC Moq unit testing against a controller that returns FileStreamResult
I am writing a test case against a controller that returns a pdf file.
Code for controller :
public FileStreamResult GeneratePdfReport(string context)
{
byte[] pdfReportContents = _helpPageBusinessService.GetHelpPagesAsPdf();
…

jeffreychi
- 199
- 3
- 14
3
votes
1 answer
c# Asp.NET MVC downloading excel file using FileStreamResult
I need to build a method, that will receive model, build excel from it (building and receiving part is done without problems) and then export (let user download it) using memory stream (without saving it on the server). I am new to ASP.NET and MVC…

rainbowShiningUnicorn
- 55
- 1
- 1
- 6
3
votes
0 answers
Response.Cache + FileStreamResult = NullReferenceException
In my mvc 4 application i have a method which is streaming a file from a azure blob.
My code is pretty simple, all im doing is fetching the blob i wanna stream and then return it as FileStreamResult with.
return new FileStreamResult(blob.OpenRead(),…

Krika
- 453
- 7
- 20
3
votes
3 answers
OutputStreamWriter java can't store into string
transformer.transform(new DOMSource(doc),new StreamResult(new OutputStreamWriter(System.out, "UTF-8")));
I'm using this to generate the output to console. I want to store the output to a sting. I don't know how to do. Can any one help me? :(
Thanks…

nixon1333
- 531
- 1
- 9
- 23