ASP.NET - open pdf file in another tab. - Asked By madhu. On 18-Aug-11 03:31 AM Hi all, i need to display the pdf file in next tab when i click link button in current page.
Active3 years, 3 months ago
How to open PDF file in a new tab or window instead of downloading it (using asp.net)? Browse other questions tagged c# asp.net pdf stream or ask your own question. 7 years, 1 month ago. C# on button click open pdf in new tab insted of downloading. Aug 25, 2011 Home / ASP.NET Forums / General ASP.NET / Web Forms / Open a PDF file in asp.net new window Open a PDF file in asp.net new window [Answered] RSS 12 replies.
Never done this before so not sure what is involved in it. I did search and found many answers but they were more complex than what I need. For example they needed to zoom in, generate, create accurate thumbnail, embed the actual PDF in the webpage, etc. But my question is much simpler:If my guy that I am showing his information on webpage has some PDF to show I just want to put a generic PDF icon on the page, people click on it and the actual PDF opens in a new tab in their browser.
https://clevernv593.weebly.com/blog/torrent-we-the-best-forever-torrent. What is involved in just doing that? It is not like a file path, the PDF is saved in SQL server as binary objects or whatever it does to save it in SQL Server.it is not a file disk path on server
Bohn
BohnBohn11.1k48 gold badges138 silver badges221 bronze badges
2 Answers
Your tags indicate asp.net-mvc.
Create a controller to handle requests for the PDF file
Pseudo:
On client
Update:
Referencing @ChrisPratt's comment; (which I forgot to include in my answer)
The
NkosiNkositarget
attribute on the anchor tag is what will tell the browser to open the link in a new tab.134k23 gold badges174 silver badges236 bronze badges
Create a Controller action to for your link
view code Xbox live free spotify premium.
FranFran5,3881 gold badge17 silver badges33 bronze badges
Not the answer you're looking for? Browse other questions tagged asp.net-mvcasp.net-mvc-5 or ask your own question.
Active1 year, 4 months ago
I have a MVC application. I need to open the pdf file when user clicks the open button on the page. The filepath where the pdf is stored is read from the database and it is a file on c:. How do I open it in my html code? I have this code:
but this doesn't open my file. Internet explorer 6 sp1 full download. What do I have to do? I need to specify somewhere that it is a pdf??
tereško53.3k21 gold badges79 silver badges137 bronze badges
TulipsTulips3545 gold badges9 silver badges21 bronze badges
5 Answers
You will need to provide a path to an action that will receive a filename, resolve the full path, and then stream the file on disk from the server to the client. Clients out in the web, thankfully, cannot read files directly off your server's file system (unless. are you suggesting
@Model.CertificatePath
is the path to the file on the remote user's machine?).Update
If
@Model.CertificatePath
is the location on the client's actual machine, try:Note that some browsers may have security settings disallowing you from opening local files.
HackedByChineseHackedByChinese38.4k8 gold badges122 silver badges137 bronze badges
Try like this in your View
Now Link will open in new window. Adobe creative cloud download error mac. You can write the pdf bytes in ViewPDF controller method
![Asp.net Open Pdf In New Tab Asp.net Open Pdf In New Tab](/uploads/1/3/3/9/133916602/958635384.png)
83.2k27 gold badges160 silver badges292 bronze badges
Jayakaran TheivendramoorthyJayakaran Theivendramoorthy8631 gold badge10 silver badges21 bronze badges
You could have the link fire a method such as the one below which will then stream your chosen file to the file download rather than opening the pdf in the broswer.
TheAlbearTheAlbear3,8277 gold badges44 silver badges77 bronze badges
Unfortunately you can't dictate where the PDF will be opened, mainly because you can't guarantee the Adobe Acrobat reader plugin is installed or how it functions.
You could in theory open a new window, and in that new window have a JavaScript function to open the PDF file, but again you can't guarantee it will open in a embedded window without the plugin, the best you can hope for is 'best try'.
John MitchellJohn Mitchell7,4588 gold badges46 silver badges83 bronze badges
Well if your getting the path value and the value is in @Model.CertificatePath
this wiil not work
You will need to add this
![Html code to open pdf in new window Html code to open pdf in new window](/uploads/1/3/3/9/133916602/581799952.gif)
and make sure you path is relative by adding this ~for example if your path is
/Content/pdfs/CertificatePath.pdf
Open Pdf In New Tab
Bluegriffon templates for websites. it would need to look like
~/Content/pdfs/CertificatePath.pdf
Javascript Open Pdf In New Window
https://cleveramerican471.weebly.com/blog/itunes-128-download-mac. Free download civil engineering books pdf format. This should be the simplest way to make it work. Hope this helps.
wilaponcewilaponce