Download file from webapi

Hi,
i'm using a button to call a custom method that downloads a file (adding a click icon in template coloumn).


The method looks like:

[HttpGet]
public IActionResult GetFile(string fileId)
{
var f = this.context.SalesforceAttachments.Where(x => x.id.Contains(fileId)).FirstOrDefault();
if (f != null)
{
string fileName = f.name;
string mimeType = "application/octet-stream";// f.contenttype;
string[] files = Directory.GetFiles(@"***", fileId + "", SearchOption.AllDirectories);
if (files.Length > 0)
{
Stream stream = System.IO.File.OpenRead(files[0].ToString());
return File(stream, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
}
}
else
{
return null;
}
return null;
}

But... chrome not download the file, If I try to use the url in the address bar it works fine.

I can solve the problem?

Thank you

Check this thread for more info: