ASP.NET MVC如何使返回的文件的行为? [英] ASP.NET MVC how to make an action that return a file?

查看:84
本文介绍了ASP.NET MVC如何使返回的文件的行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好
我生成我的行动里一个Excel文件,我将返回给用户。我如何有申报行动回报文件?

Hello I am generating an excel file inside my action that I would return to the user. How do I have to declare the action to return a file?

我可以叫使用Ajax这个动作?

May I call this action with ajax?

谢谢!

推荐答案

方法1:使用内置的ActionResults,如FilePathResult,FileStreamResult,FileContentResult

Option 1: Use built in ActionResults, such as FilePathResult, FileStreamResult, FileContentResult

选项2:创建一个自定义的ActionResult返回Excel文件(例如:的http://www.dotnetcurry.com/ShowArticle.aspx?ID=484&AspxAutoDetectCookieSupport=1)

Option 2: Build a custom ActionResult to return your excel file (example: http://www.dotnetcurry.com/ShowArticle.aspx?ID=484&AspxAutoDetectCookieSupport=1)

这篇关于ASP.NET MVC如何使返回的文件的行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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