Questions tagged [fileresult]

74 questions
0
votes
1 answer

How return a yaml file as result of an asp.net core ViewComponent

I want to create an asp.net core ViewComponent that dynamically return a yaml file based on some criteria: For example namespace MyNameSpace { [ViewComponent(Name = nameof(MyViewComponent))] public class MyViewComponent : ViewComponent { …
0
votes
1 answer

Pass Anonymous Type

I am trying to create a utility class where I could pass a list of Anonymous Type (AT) and it would produce a CSV file with the AT's properties as its columns and property values as its respective data. I have a working code but I feel it could be…
Jose Capistrano
  • 693
  • 1
  • 8
  • 20
0
votes
1 answer

download a file from server using a controller and javascript

I have the controller code below: public FileResult DownloadFileParaView() { byte[] fileBytes = System.IO.File.ReadAllBytes(@"MyPath"); string fileName = "MyFileName"; return File(fileBytes,…
Gugalaxia
  • 3
  • 1
0
votes
0 answers

Switch from Visual Studio 2012 --> 2019 Broke async Task and FileResult

An ASP.NET MVC solution that was working fine in VS 2012 stopped working in 2019 and I cannot find what has changed to break it. Originally I had the code in the first block - the async task would go to the file storage and retrieve the file, and…
0
votes
1 answer

How to handle download return File Result from controller ? MVC

I am not able to download file result in js. I am returning File Result to the js but dont know how to download it To be short and specific i am returning word document from controller to js in which i need to download it and handle it in js. My…
Doc
  • 179
  • 1
  • 18
0
votes
0 answers

FileResult Download does not trigger

I can't seem to trigger the download file actionresult. I have the following code. HTML: JavaScript: $('.excelLink').click(function () { var url =…
0
votes
2 answers

How To Download A file From FileResult and anchor tag in MVC 5?

THIS IS MY FILE UPLOAD AND DOWNLOAD CODE [HttpPost] public ActionResult Save(Rent Rent , FileUpload upload, HttpPostedFileBase file) { if (Rent.Id == 0) _Context.Rent.Add(Rent); else { var…
0
votes
1 answer

ASP.NET MVC How to output FileContent from within a controller action and continue

I am fairly new to MVC and want to know what the correct approach is - when a form is submitted the Edit ActionResult is executed, once the data is saved, I want to generate a file and send to the browser for download but also continue to another…
Darren K
  • 1
  • 1
0
votes
1 answer

MVC5 Calling FileResult Action redirects to Account/Login

I am calling a FileResult action like this: [AllowAnonymous] public FileResult DownloadDocument(int documentId){// My code} But it keeps redirecting to Account/Login, I dont even have a Login page. This is only happening when I deploy the…
Juan Alberto
  • 165
  • 3
  • 18
0
votes
0 answers

ASP.NET Core 2 Controller's ActionMethod async Task returns HttpresponseMessage

UPDATE: As I mentioned I changed my action method, no success. See screenshots The result is the same, no matter: Briefly summarising my problem: Everything is in dot net core 2.0. I have a WebAPI (separate project) and its Controller (talking to…
0
votes
0 answers

NullReferenceException in SiteLayout.cshtml with FileResult

For a client of ours we have an MVC action which returns PDF files. The following code is the logic to return the FileResult. public FileResult DownloadAbsFile(string id) { String path = GetPathNameByID(id); if (System.IO.File.Exists(path)) …
Bas Kooistra
  • 129
  • 1
  • 2
  • 6
0
votes
1 answer

How to generate interchangeable download links?

i'm tying to make DL link so others couldn't dl the same file by sharing it so far i've found this code public FileResult Download() { byte[] fileBytes = System.IO.File.ReadAllBytes(@"c:\folder\myfile.ext"); string fileName =…
Mostafa Bouzari
  • 9,207
  • 3
  • 16
  • 26
0
votes
2 answers

MVC - ActionLink looks for a view instead of calling of controller method

I would like to create link on my site, which, after click, would open download window (just some simple text file). In several tutorials I found a way to do it, however, for some reason, it seems that ActionLink doesnt call my method and looks for…
Jozef
  • 479
  • 1
  • 9
  • 36
0
votes
1 answer

Download File from web browser to desktop from MVC5

I have an MVC5 project, and it has a view that allows a user to download documents from SQL Server. This view is a form page with one or more file input controls that allow a user to upload any file types. When a user selects a file from the…
J. Zacka
  • 139
  • 2
  • 2
  • 12
0
votes
1 answer

angular js - stop displaying images once overflow is reached

I have a bunch of images that im serving up (from an external source im hosting elsewhere) onto a page via an mvc fileresult and into an angular ng-src. eg.
xxdefaultxx
  • 175
  • 1
  • 12