Hello,
I need to be able to export csv data through an MVC module.
I've been able to get it working with the following:
public FileContentResult Export()
{
StringBuilder sb = new StringBuilder();
//create csv lines here
return File(new System.Text.UTF8Encoding().GetBytes(sb.ToString()), "text/csv", string.Format("PickupExport-{0:yyyyMMdd}.csv", System.DateTime.Now));
}
But, I'm not sure how to run this... I added a control for "Export"... and that works, but it moves me to that Url and it appends the HTML output into the file.
Can anybody see what I'm doing wrong?
Thanks.