Asp.net Open Pdf In New Tab

Disclaimer: This site is started with intent to serve the ASP.Net Community by providing forums (question-answer) site where people can help each other. The content posted here is free for public and is the content of its poster. The site does not provide any warranties for the posted content. When you have e.g. An ASP.NET http handler that reads the file from the database. When that handler is named 'pdf.ashx', you can simply open a new window from Silverlight that points to it. Use query parameters to e.g. Select the correct pdf from the database using ids or names.

Active5 years, 1 month ago

This question already has an answer here:

Asp.net Open Generated Pdf In New Tab

  • Opening a hyperlink in a new tab in ASP.NET 6 answers
  • Response.Redirect to new window 20 answers

I need to open an aspx page in a new tab, I searched differents solutions, but I've only found codes that open pop-ups and the browser blocks. I need to do it in the code behind

I hope somebody help me, THANKS.

Randall Sandoval
Asp.net Open Pdf In New TabAsp.net Open Pdf In New TabRandall Sandoval

Html Open Pdf In New Tab

Randall Sandoval
1591 gold badge5 silver badges17 bronze badges

Javascript Open Pdf In New Window

marked as duplicate by gunr2171, lucuma, Christos, Frank van Puffelen, reneJul 12 '14 at 20:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

You cannot open a new page from code behind. Instead, you need to open at client side.

The problem of opening at client side is sometime pop-up blocker blocks the page.

WinWin
47.7k9 gold badges73 silver badges144 bronze badges
Open pdf in new window

The short answer is: you can't.

Open Pdf In New Tab Using Asp.net

You especially can't do it from the server — there, you have zero access to browser functionality.

And on the client side of thing, you have very little direct access to browser functionality outside your own 'window'.

The best you can do is open a new window with a target window name of _blank. You can do that with HTML, thus:

When the user clicks the link a new window should open (but, see below).

You can do it with javascript, thus:

Asp.net Open Pdf In New Tablets

What happens then is entirely dependent on the browser and how the user has configured it:

  • It might not open at all (is a pop-up blocker running?),
  • It might open a new tab,
  • It might open a new window

One might note, too that a straight link without a window name might open in a new tab or window, too. For instance, I have my Firefox configured to open off-domain links in a new tab by default, and to open all target='_blank' links in a new tab rather than a new window.

Nicholas CareyNicholas Carey
51.6k11 gold badges71 silver badges110 bronze badges

Not the answer you're looking for? Browse other questions tagged c#asp.nettabs or ask your own question.