Don Thomas Boyle
Don Thomas Boyle

Reputation: 3045

Opening PDF in new Window

I'm Working in MVC vb.net with asp.net engine instead of Razor.

I'm returning the file like so

1. Return File(xStream, "application/pdf")

and

2. Return File(xStream, "application/pdf", "NameOfFile.pdf")

In my Asp.net page I call the Report like so

<a id="report" href="<%: Url.Action("report", "Report", New With {.id = Model.reportID})%>" target="_blank">Print</a>

Using the first return from above, i get the stream in the browser -> good, except it's not in a new window.

Using the second return from above, i get the stream as a downloaded file.

How can i change my code to open the pdf report like in return 1, exept in a new window?

EDIT:

recently tried scripting the button to use

window.open('<%: Url.Action("Report", "Report", New With {.id = Model.ReportID})%>','_blank');

however this opens a completely new window, i'd like to have a tab opened.

Upvotes: 0

Views: 3178

Answers (1)

workabyte
workabyte

Reputation: 3755

do not believe this has changed much. There was a way to force a new window over a new tab by defining other attributes of the window with you opened it ie: size, location but the determining factor as to the pop up being in a new tab or new window is up to the browser/settings.

another similar question

Upvotes: 1

Related Questions