PDF File Not Opening In Web Browser

I'm trying to open a PDF file in my web browser.  I get the open/save dialog box and when I click open it just open Adobe Acrobat Reader, it won't display in my browser.

If (file.Exists) Then
Response.Clear()
Response.AddHeader("Content-Disposition", _
"attachment; filename=" + file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/pdf"
Response.WriteFile(file.FullName)
Response.Flush()
Response.End()
End If
Thanks for the help
Brandon W.
0
b8ball02
3/9/2005 5:08:27 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

4 Replies
1240 Views

Similar Articles

[PageSpeed] 14
Get it on Google Play
Get it on Apple App Store

Hi,

I also saw similar behavior when using acrobat 7. I opened a pdf file but it opened acrobat as a standalone application. After switching back to the browser, I saw that the pdf file was actually opened in the browser. Strange.
Grz, Kris.
Read my blog. Handy Firefox plugins for web developers.


Workaround for non working Mark as answer buttons.
0
XIII
3/9/2005 7:02:39 PM
I have an app that streams dynamically generated PDFs using code I got from Crystal. It uses similar code to yours, but doesn't have the AddHeader calls you're using.

i.e.

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(Fname)
Response.Flush()
Response.Close()
System.IO.File.Delete(Fname)

It looks like it isn't necessary to declare the file as an attachment if you want it to open directly in the browser.
0
rohan_p
3/10/2005 12:00:54 AM
Hi,

that's correct. The attachment is used for returning data in your browser and popup an instance of the program to open the attachment with.
Grz, Kris.
Read my blog. Handy Firefox plugins for web developers.


Workaround for non working Mark as answer buttons.
0
XIII
3/10/2005 7:59:50 AM
Well I got it working so for anybody that wants to know changing the line:

Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name)
to
Response.AddHeader("Content-Disposition", "inline; filename=" + file.name)

Do this cause my program to go from the dialog of open or save to just opening straight into the browser.
0
b8ball02
3/10/2005 1:11:14 PM
Reply:

Similar Artilces:

how open pdf file in another web browser?
hi this is my code to open a pdf file in a web browser.Dim strCmd As String = e.CommandName Dim strArg As String = e.CommandArgumentIf strCmd = "_VIEW" Then Dim strFullPath As String = strArgDim fileName As String = Path.GetFileName(strFullPath) Response.Clear() Response.ClearHeaders()Response.AddHeader("Content-Disposition", "inline;filename=" + fileName) Response.ContentType = "application/pdf"Response.WriteFile(Server.MapPath("~/File/") & strFullPath) Response.Flush() Response.[End]() End If How can i open it in a ...

web web web
Name: bahadir Email: sensiz_olmuyor_t1_at_hotmail.com Product: Firefox 2 Beta 2 Summary: web web web Comments: web sayfası yapmak Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2 ...

how to open .exe file in a web form in vb.net?
hi, Are there any one who know to open .exe file from a web form application? make a link like: My Exe ...

How to get HTML Source of web page opened by web browser using vb.net
hello friends,         i have opened an web browser in vb.net using the below code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim nullObject As System.Object = 0 Dim str As String = "" Dim nullObjStr As System.Object = str Windows.Forms.Cursor.Current = Cursors.WaitCursor Dim i As Int16 For i = 1 To 2 AxWebBrowser1.Navigate("http://www.google.co.in/search?hl=en&q=test&meta=", True) AxWebBrowser1.Document. Next Windows.Forms.Cursor.Current = Cursors.Default End Sub  ...

WEB FORMS and datasetS (do I have to repeat the file definition in every web form?)
I am working on vb.net.I have a project with 35 web forms and an access file with 18 tables.Until now I have defined the oledbadapters in every form by dragging the tables from the server explorer tool box.This is not a good idea because every time that I make a change on the database design I have to drag the new definition on 35 web forms and I have to create the datasets again. This is boring and time consuming!The question is:WHAT CAN I DO TO HAVE THE FILE DEFINITION ONLY IN ONE PLACE AND THAT EVERY WEB FORM WOULD TAKE THE DATA ADAPTERS AND DATASETS FROM THERE? how about if you write a...

Open web page in IE and populate fields on the form from my web form
To the dot net Knights.  Many humble thanks in advance from a dot net surf. We have an vb application that opens multiple instances of IE object, each to different web pages.  It then takes information from the current record in the app, populates fields on each of the web pages, and them submits the forms.  We are then able to look at the resulting web pages and quickly get the info we're looking for.This prevents us from having to manually navigate to each web site, enter the same information and then wait for the page to open.  If there is ...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Opening files from a web form
Hey there, What I want to do is have  list box which displays all the files in a folder on the server and then the user can double click on them, or click on them and click a button and open them! atm I have the files displaying using   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim windir As String Dim file As String windir = ("C:\Inetpub\wwwroot\Fileviewtest\Data") Me.ListBox1.Items.Clear() Dim files() As String = Directory.GetFiles(windir) For Each file In files Me.ListBox1.Items.Add(System.IO.Path.GetFil...

Opening a File in a Web Form
Good Morning,I need some assistance with an assignement i need to accomplish the next couple of days. I need to in a web form select a file and have some informations about the file being visible by the code in the web form. What component can i use, or what classes to upload a file?? thks PipiMeiasAltas--Regarding this... PipiMeiasAltas wrote:...I need some assistance with an assignement i need to accomplish the next couple of days. I need to in a web form select a file and have some informations about the file being visible by the code in the web form. What component can i use, or w...

opening a file in web browser
 hello,I Have a requirement where i need to open a file in a new  browser.im using the following code but it is displaying a dialog box which consists of 3 buttons open,save,cancel.when u click open button of the text file ,the file will be opened in notepad,if it is .doc file it will be opened in microsoft word.             string filename="xyz.txt";            Response.ContentType = "application/doc";            Respo...

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

how to open a web page in form of a popup web page
Hello, I have two web pages, let say. Page A : With a Button on it. PAge B: with some info. Now I need to: When I click on the Button of page A.Page B must open in a pop up window.  I can do this but problem is this when I clicked on the button for first time it does not show me any thing and when I clicked on the button for second time then It shows me Page B .My code is as follow:  1 protected void Page_Load(object sender, EventArgs e) 2 { 3 if (!this.Page.IsPostBack) 4 { 5 6 } 7 else 8...

How to File Upload and Download file ( .doc/.pdf/.gif/.exl) from server web browser C#
How to File Upload and Download file ( .doc/.pdf/.gif/.exl) from server web browser Please help me Thanking you Saikat   Uploading: Try a Google search for upload file web server asp.net c#. Download: <a href="http://www.mydomain.com/pathtofile">Download Me</a> HTH,RyanRyan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question HiI want to download this logo.gif . It is possable to download. Download: <a href="http://www.google.com/intl/en/images/logo.gif">Download Me</a> and How to File Upload .doc/.pdf/.gif/.exl file we...

Web resources about - PDF File Not Opening In Web Browser - asp.net.web-forms

Encyclopaedia of Chess Openings - Wikipedia, the free encyclopedia
The Encyclopaedia of Chess Openings (or ECO ) is a classification system for the opening moves in a game of chess . It is presented as a five-volume ...

INFOGRAPHIC: Major League Baseball Facebook Standings At Opening Of 2013 Season
The New York Yankees may be injury-plagued and off to a sluggish start to the 2013 Major League Baseball season, but when it comes to Facebook ...

Into Film Festival opening Q&A
Today I met Malala. She was giving, utterly graceful, compelling and intelligent. That might sound obvious but I was struck by this even more ...

American College Football season 2016: Sydney host opening fixture - DailyTelegraph Search Search
CHEERLEADERS, marching bands, crazy fans, a giant pack of fearsome Golden Bears and an army of Hawaiian Warriors will take over Sydney in a $10 ...

Countdown to Flagstaff Station opening on weekends
Flagstaff railway station will be open on weekends at some time in the next 32 days.


Porsche opening network of dedicated Classics centers
Filed under: Porsche , Auto Repair , Maintenance , Classics The first dedicated Porsche Classic Center has opened in the Netherlands, paving ...

Spanish band Hinds talk debut LP, the Madrid scene, opening for The Libertines, and more
by Tatiana Tenreyro Madrid garage rock band Hinds' singers/guitarists Carlotta Cosials and Ana García Perrote initially started out as a duo ...


Opening Arguments Begin In Trial For Officer Charged In Gray’s Death « CBS Baltimore
A jury is seated, opening statements are complete and the prosecution calls its first witness in the trial for one of six officer’s charged in ...

Resources last updated: 12/4/2015 8:06:03 PM