Recommended way to create an ActionResult with a file extension

前端 未结 4 1465
余生分开走
余生分开走 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:52

    This is how I'm doing something similar. I'm treating it as a download:

    var disposition = String.Format(
      "attachment;filename=\"{0}.csv\"", this.Model.Name);
    Response.AddHeader("content-disposition", disposition);
    

    This should show up in the browser as a file download with the given filename.

    I can't think of a reason why yours wouldn't work, though.

提交回复
热议问题