I want to make ability to download attachments from my site, (I need to make it runs in IE) so in html I have:
<a href="api/attachments/DownloaAttachment?id={{attachment.Id}}" target="_blank">
Download Image
</a>
<!-- {{attachment.Id}} - it's because I use AngularJS :) -->
in controller:
[HttpGet]
public FileContentResult DownloaAttachment(int id)
{
var att = GetAttachmentById(id);
byte[] fileBytes = att.Content.Content;
var response = new FileContentResult(fileBytes, MediaTypeNames.Application.Octet);
response.FileDownloadName = att.FileName;
return response;
}
but when I click on "Download Image" - I have a new window and responce from controller as json, like:
{"FileContents":"/9j/4.. some bytes..ZK9k=","ContentType":"application/octet-stream","FileDownloadName":"Cover.jpg"}
But I don't need that JSON, I need to be able to download attach as file to user's computer. How can I make it as simple file download? What am I do wrong?