I have an icon that when clicked calls a controller and it converts the array into bytes in PDF and this opens the document in the same window.
I need the document to open a new windows in the browser in the same tab.
Icon that calls controller using URL action.
<div class="col-sm-1">
<a href="@Url.Action("GetPDF", "Home" , new { item.Id })"> <i class="fas fa-eye"> </i></a>
</div>
Controller that converts bytes to PDF.
public async Task<ActionResult> GetPDF(Guid id)
{
var vm = new ViewModels.Home.AttachmentViewModel();
var result = vm.GetServiceAttachment(id));
//Function to get the file information from DB .
byte[] file;
foreach (var attachment in result)
{
file = attachment.File;
byte[] byteArray = file;
return new FileContentResult(byteArray, "application/pdf");
}
return null;
}