Google Chrome has this really neat feature that it opens .pdf Files in a new tab if supplied by the page correctly on download.
I was wondering how to achieve this in the latest revision of .NET Core?
My current configuration looks like this:
Backend:
[HttpGet("download")]
public IActionResult DownloadHelpFile()
{
string path = Path.Combine(_environment.WebRootPath, "files/dummy.pdf");
var net = new System.Net.WebClient();
var data = net.DownloadData(path);
var content = new MemoryStream(data);
var contentType = "application/pdf";
var fileName = "dummy.pdf";
return File(content, contentType, fileName);
}
Frontend:
<a asp-action="DownloadHelpFile" _target="blank">@CasesLocalizer["NeedHelpDownloadOurGuide"]</a>
I also swapped _target= 'blank' with 'new'. I have searched on google and on StackOverflow and did not find anything updated for ASP.NET Core that works.
It still just downloads the file regularly but does not display the PDF in a new tab. What is my code missing?