Questions tagged [fileresult]

74 questions
1
vote
0 answers

how do we redirect to File Result from ActionResult controller in mvc asp.net

How can I call a FileResult controller in a MVC project using a ajax call to download a file on the click of a button. I have tried the following code but getting an error every time. If I call it using @Ajax.ActionLink() I am successful but I need…
1
vote
1 answer

Prevent FileResult chunked response

I have an ASP.NET Core 1.2 application which sends a file to a user. I use a FileResult for this purpose. My code looks like: return PhysicalFile(Path.GetFullPath(filePath), QMimeTypeMap.GetMimeType(Path.GetExtension(file.Name))); I have tried…
Hele
  • 1,558
  • 4
  • 23
  • 39
1
vote
2 answers

ASP.NET MVC FileResult with specific Filename and Safari or Chrome

I'm having problems with FileResult returning a file with a specific filename. In the database the filename is just and ID + extension (e.g: 456789.mp3) This piece of code FileStream fs = new FileStream(filePath, FileMode.Open,…
ShyGuy82
  • 115
  • 2
  • 6
1
vote
4 answers

FileResult returning corrupt file

I'm creating a simple controller action in ASP.NET MVC 2 (under the .NET 4.0 framework) which will resize files. I've got a controller like this (I've cut it down a bit): public ActionResult GetFile(int fileId, string fileSource) { FileInfo file…
Aaron Powell
  • 24,927
  • 18
  • 98
  • 150
1
vote
1 answer

How I could pass a parameter to an CSV export method in MVC controller with Jquery/Ajax

On my view I have a button for export in CSV the current data view. This is a simple link to a method in the controller.
mrplume
  • 183
  • 1
  • 3
  • 18
1
vote
1 answer

Trouble exporting to excel from mvc action

I created a simple action to download some content as excel file: public FileResult ExportToExcel() { string filename = "list.xlsx"; string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; …
nickornotto
  • 1,946
  • 4
  • 36
  • 68
1
vote
1 answer

How to not ask the user for download prompt and set the download path programmatically?

I am developing an ASP MVC controller that returns a FileResult. In the browser, I do not want to show the download prompt and download the file to a specific location on he client machine. Is it possible please?
Cheb Bilel
  • 61
  • 1
  • 11
1
vote
2 answers

Why this action results an empty file on client side?

Why this action results an empty file on client side ?? public FileResult download() { MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); FileStreamResult fs = new FileStreamResult(stream,…
Mauro
  • 93
  • 1
  • 7
1
vote
1 answer

How to display an image like popup from View

I created an QR code image using MessagingToolkit.QRCode.dll in a button click. I have saved the image in the disk. How to display the image separately from view as pop up ?? Here is my controller code : [HttpPost] public ActionResult…
kk1076
  • 1,740
  • 13
  • 45
  • 76
1
vote
1 answer

ASP.net MVC 3 wont download the file generated

Here's the code snippet from my Controller... it all starts at my Index. public ActionResult Index(...){ //some code here return GenerateReport(...); } So far...exporter.GenerateReport() returns the correct path of the generated…
JYR
  • 109
  • 4
  • 15
1
vote
4 answers

Downloading excel file in asp.net mvc

What I'm trying to implement is giving the users the ability to export the grid data to an excel file and download it, with the help of a file save dialog. Here's how I have coded it right now - In Javascript - $.post("/irn/Identifier/Download", {…
neuDev33
  • 1,573
  • 7
  • 41
  • 54
1
vote
1 answer

MVC ASP.NET Return response.GetResponseStream() as FileResultStream

I am trying to write a controller that creates and makes a HttpWebRequest to a service that returns an Image. I then want to return this image as a FileResult. How do I go about doing that. I have tried the code below but it returns a corrupted…
Matt
  • 334
  • 5
  • 15
0
votes
1 answer

How can I get the full path of a captured picture in .NET MAUI for Mac Catalyst platform?

I’m trying to implement a function to capture and attach a picture in .NET MAUI. It seems to be correctly working on all platforms but MAC Catalyst. The issue seems to be the FullPath property of the FileResult (Microsoft.Maui.Storage) object…
0
votes
1 answer

Override Content-Length header with a custom value

I have a controller returning an image, but the image was cut off at the bottom in the front-end (in the browser), after some digging I found out it's because the Content-Length response header was smaller then the actual file size (by some 500…
big boy
  • 315
  • 2
  • 13
0
votes
1 answer

how to handle respond of fileResult in Javascript

The controller: [HttpGet] public FileResult Get() { //execute sql using (XLWorkbook wb = new XLWorkbook()) { wb.Worksheets.Add(dt, "file"); using (MemoryStream stream = new…
Panos
  • 53
  • 5