ASP.NET MVC how to make an action that return a file?

旧街凉风 提交于 2019-12-21 12:43:18

问题


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?

May I call this action with ajax?

thanks!


回答1:


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

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



来源:https://stackoverflow.com/questions/3935225/asp-net-mvc-how-to-make-an-action-that-return-a-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!