I inherited from FileResult and it did not download - even though I set download name
I did this and it works
public FileResult DownloadTextAsAFile(string data, string name)
{
string fileName = string.Format("{0}.csv", name);
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data);
return new FileContentResult(bytes, "application/vnd.ms-excel") { FileDownloadName = name };
}
No comments:
Post a Comment