I am using as below:
html += '
public ActionResult ViewPdf(decimal id)
{
Departmententity entity = new Departmententity();
byte[] data = entity.GetnocPdf(id,deptcode, uniqid);
return File(data, "application/pdf");
}
when i use this pdf open in same tab.
I want to open in different tab.
Jayraj ChhayaPosted Dec 22, 2023, 5:57 AM
To open a PDF file in a new tab using the
target="_blank"attribute, you need to make sure that thedownloadattribute is not present in the anchor tag. Thedownloadattribute is used to specify that the target should be downloaded instead of displayed in the browser.In your code snippet, you have included the
downloadattribute in the anchor tag. To open the PDF file in a new tab, you should remove thedownloadattribute. Here's an updated version of your code:By removing the
downloadattribute, the PDF file will now open in a new tab when the user clicks on the "Download" link.Additionally, make sure that the
hrefattribute in the anchor tag points to the correct URL that retrieves the PDF file. In your provided code, thehrefattribute is set tohyperlinks='/Department/ViewPDF/'. Make sure that this URL is correct and returns the PDF file.With these changes, the PDF file should open in a different tab when the user clicks on the "Download" link.