【发布时间】:2018-05-29 07:35:05
【问题描述】:
namespace Tema2_PS.Services
{
public class CSVExporter : Exporter
{
public FileContentResult convert(List<Ticket> ticketList)
{
string csv = "";
return File(new System.Text.UTF8Encoding().GetBytes(csv.ToString()), "text/csv", "Export.csv");
}
}
}
【问题讨论】:
-
你肯定是指
return new File(...).. 但即便如此File肯定不能转换为FileContentResult。但是我们不知道这两个类是如何相互依赖的,因此不知道如何进行这种转换。 -
File是Controller中的一个方法。您的代码不在控制器中,因此无法编译。因此,您将希望new向上FileContentResult。