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

Hi I am creating an excel file inside my action in order to return to the user. How do I declare an action to return a file?

Is it possible to call this action with ajax?

thanks!

+6
asp.net-mvc asp.net-mvc-2
source share
1 answer

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

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

+16
source share

All Articles