Recommended way to create an ActionResult with a file extension

前端 未结 4 1473
余生分开走
余生分开走 2020-12-24 02:58

I need to create an ActionResult in an ASP.NET MVC application which has a .csv filetype.

I will provide a \'do not call\' email list to my marketing partners and i

4条回答
  •  无人及你
    2020-12-24 03:50

    The answer you accepted is good enough, but it keeps the content of the output in memory as it outputs it. What if the file it generates is rather large? For example, when you dump a contents of the SQL table. Your application could run out of memory. What you do want in this case is to use FileStreamResult. One way to feed the data into the stream could be using pipe, as I described here

提交回复
热议问题