Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Generate a Link to download a File in asp.net MVC?

I am testing Doddle Report to generate a few report form a IEnumerable object. I need to generate a Link like this

PDF - http://myserver.com/reports/ProductsReport.pdf

The Question is how do I do this?

En Stop Using Doddle Report, and generate del Excel in XML format.

like image 640
Jedi Master Spooky Avatar asked Nov 28 '22 20:11

Jedi Master Spooky


1 Answers

Check out this tutorial to return different action result.

The ASP.NET MVC framework supports several types of action results including:

  • ViewResult – Represents HTML and markup.
  • EmptyResult – Represents no result.
  • RedirectResult – Represents a redirection to a new URL.
  • JsonResult – Represents a JavaScript Object Notation result that can be used in an AJAX application.
  • JavaScriptResult – Represents a JavaScript script.
  • ContentResult – Represents a text result.
  • FileContentResult – Represents a downloadable file (with the binary content).
  • FilePathResult – Represents a downloadable file (with a path).
  • FileStreamResult – Represents a downloadable file (with a file stream).
like image 132
J.W. Avatar answered Dec 10 '22 22:12

J.W.