0
У меня есть метод, который был написан в ASP.net MVC контроллер:ASP.Net ApiController как заменить Controller.Response
[HttpGet]
public void ExportClientsListToCSV()
{
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment;filename=Exported_Contacts.csv");
Response.ContentType = "text/csv";
Response.ContentEncoding = Encoding.Unicode;
Response.BinaryWrite(Encoding.Unicode.GetPreamble());
StringWriter sw = new StringWriter();
sw.WriteLine("\"FullName\",\"Position\",\"BranchOffice\",\"PrivateEmail\"");
foreach (var line in db.Persons)
{
sw.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\"",
line.FullName,
line.Position,
line.BranchOffice,
line.PrivateEmail);
}
Response.Write(sw.ToString());
Response.End();
}
Я хочу, чтобы использовать его в ApiController, но в ApiController Нет участника Ответ. Как я могу его заменить? Существует HttpResponseMessage, но я не могу с ним поделать.
Благодарим за помощь!
Спасибо большое! Это действительно работает! – Bodryi