如何生成链接在asp.net MVC中下载文件? [英] How to Generate a Link to download a File in asp.net MVC?

查看:134
本文介绍了如何生成链接在asp.net MVC中下载文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试 Doddle Report ,以生成一个IEnumerable对象的几个报告。我需要生成一个这样的链接

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

问题是我该怎么做?

en停止使用Doddle Report,并以XML格式生成del Excel。

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

推荐答案

查看这个教程返回不同的动作结果。

Check out this tutorial to return different action result.

ASP.NET MVC框架支持多种类型的动作结果,包括:

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


  • ViewResult - 表示HTML和
    标记。

  • EmptyResult - 不表示结果。

  • RedirectResult - 表示向新URL发送
    重定向。 / li>
  • JsonResult - 表示AJAX应用程序中可以使用
    的JavaScript
    对象符号结果。

  • JavaScriptResult - 表示一个
    JavaSc ript脚本。

  • ContentResult - 表示一个文本
    结果。

  • FileContentResult - 表示
    可下载文件
    内容)。

  • FilePathResult - 表示
    可下载文件
    (使用路径)。 li>
  • FileStreamResult - 表示
    可下载文件(文件
    流)。

  • 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).

这篇关于如何生成链接在asp.net MVC中下载文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆