Lorenzo
Lorenzo

Reputation: 29427

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

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!

Upvotes: 6

Views: 5341

Answers (1)

Retired_User
Retired_User

Reputation: 1595

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)

Upvotes: 16

Related Questions