Questions tagged [filestreamresult]

57 questions
0
votes
1 answer

Downloading a file without extension from a folder to file with extension on browser in .net core

There are word files and pdf files stored in a folder without extensions. When we open these files with pdf view or word viewer the corresponding files gets rendered. Now the requirement is to download these files from .net core application on click…
Tarun J
  • 17
  • 4
0
votes
0 answers

System.ObjectDisposedException: Cannot access a disposed object. C#

FileController.cs public IActionResult GetFileByName(string name) { return _file.GetFile(name); } FileRepository.cs public FileStreamResult GetFile(string name) { string path = "C:\\" FileInfo fileInfo = new fileInfo(path); …
0
votes
1 answer

AspNet Core - Could not load the image from FileStreamResult

Please help. I've been searching for hours now as I cannot display the image on the website. I'm using byte[] from database then return FileStreamResult in controller. Below is my code .cshtml User…
Mary
  • 564
  • 3
  • 14
0
votes
1 answer

FileStreamResult displays empty browser document when rendering image from stream in MVC3

I have a fairly simple Action in an MVC3 application that should render an image... public FileStreamResult Photo(int id) { //get the raw bytes for the photo var qry = from p in db.Photos where p.PhotoID ==…
Baldy
  • 3,621
  • 4
  • 38
  • 60
0
votes
0 answers

Decode Base64 and stream on the fly

I have a situation where I have PDF files stored in a database as Base64 data in VARCHAR(MAX) columns. These are accessed from an ASP.NET Core MVC app. Users need to be able to view and download these files in a browser. Currently, we return the…
Valuator
  • 3,262
  • 2
  • 29
  • 53
0
votes
1 answer

How do I get details from ViewBag into a string for use in FileStreamResult?

Hello clever coding people, I am working on a MVC project for college, and I am trying to output an invoice, I do not need to view the invoice, just create a downloadable text file. I have been trying to use StringBuilder to get the details from…
0
votes
2 answers

Cannot access a closed Stream when returning FileStreamResult from C# .NetCore API

C# .Net-Core 3.1 In my C# api I am returning a pdf file in a FileStreamResult, works great. Generally I wrap streams in using, however this code fails with Cannot access a closed Stream. using (MemoryStream stream = new MemoryStream(byteArray)) { …
kpg
  • 589
  • 6
  • 28
0
votes
0 answers

Redirect to Web API FileStreamResult from MVC Action

I am trying to redirect from my MVC application to a FileStreamResult in my web api. The MVC side needs to do a post because of the data that is being sent over. The basic idea is that I should be able to post in the MVC side and what happens next…
0
votes
1 answer

Use NPIO To Make Excel Then Send Back With FileStreamResult?

I am trying to make an excel file and then send it back via the FileStreamResult. I am using asp.net core I am starting to use NIPO example var newFile = @"newbook.core.xlsx"; var fs = new MemoryStream(); IWorkbook…
chobo2
  • 83,322
  • 195
  • 530
  • 832
0
votes
0 answers

how to send multiple emails at one session using JAVA

i have a XML, where with that XML i mocked up test data by passing it in excel, i stuck up in getting the multiple mocked up string formatted files to send it to queue as a string. this is my string formatted mocked up file stored in…
0
votes
2 answers

ASP.Net core redirect to an action which return FileStreamResult

I have to actions in a controller: [Route("api/[controller]")] [ApiController] public class ValuesController : ControllerBase { [HttpGet("redirect1")] public IActionResult Redirect1() { var r =…
0
votes
2 answers

What is the difference between the these two FileStreamResult from different classes?

What is the difference between System.Web.Mvc's FileStreamResult and Microsoft.AspNetCore.Mvc's FileStreamResult? Is there any significant take away of using the latter over the first one? Edit: Is it possible to have .Net Core project but still use…
CodeRed
  • 905
  • 1
  • 6
  • 24
0
votes
1 answer

"Save As" dialog before download

I have a function in the controller that downloads a configurations: public FileStreamResult SaveData() { var toJson = JsonConvert.SerializeObject(this.GetData()); var byteArray = System.Text.Encoding.ASCII.GetBytes(toJson); var stream…
tolik
  • 187
  • 1
  • 10
0
votes
1 answer

Using FileStreamResult to display PDF in browser

I am trying to display a PDF file in a browser using the action below. When this is executed the result is an entire screen that looks like the image attached. Rendered result It looks like MediaTypeNames.Application.Pdf is being ignored. The same…
haler
  • 3
  • 4
0
votes
1 answer

Get FileStreamResult using ajax asp.net core

I had a function in controller named Export [HttpPost] [ActionName("Export")] public async Task Export(int a) { var fileStream = new MemoryStream(); var contentType =…
Sam sam
  • 33
  • 8