By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,589 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,589 IT Pros & Developers. It's quick & easy.

Problem opening PDF file written to browser

P: n/a
In several aspx applications I export crytal reports to pdf, xls and doc
files and then the aspx page writes the selected export file to the client
browser. This all works with one small quirk: When I run any of the web
apps on my workstations iis website, the pdf download always produces the
"File Download" dialog, even though I have Confirm after Download turned
off. When I select to Open the file from this dialog the file opens in
Visual Studio...yes, the binary file is in the VS editor. If I save that
file from VS as a .pdf file it opens correctly in acrobat. From the
browser, if I select the File Download dialog option to Save the file, I
can open the saved file with acrobat.

Now the catch......If I run the ***exact*** same web apps from a web server,
accessing any one of them from my pc's web browser, the pdf downloads work
correctly....opening without a dialog and opening in acrobat reader. This
use to work correctly on my local pc and I have no clue as to what could
have changed to break it. Thinking the acrobar settings hosed I reinstalled
acrobat. I also tried an uninstall of VS2003 and tried the web apps and the
only difference was that the pdf file opened in notepad.

No problems with the xls and doc file export and downloads, they work
correctly from my local web site and server.

Why would a pdf download work differently when accessed from a local web
apps versus a server...produce by same .net code...viewed by same browser.?
workstation OS win2003 server
VS 2003 .net 1.1
Acrobat Pro 6.0
browser IE 6
Brad
Brad
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Brad" <no****@co.lane.or.us> wrote in
news:uY**************@TK2MSFTNGP10.phx.gbl:
Why would a pdf download work differently when accessed from a local
web apps versus a server...produce by same .net code...viewed by same
browser.?


Most likely the MIME mapping. What Response Content Type are you using?
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #2

P: n/a
Hi Brad,

From your description, you write down a pdf stream to the client browser.
However, currently, you found the pdf stream can be correctly opened in
acrobat reader at other remote clients but failed on local (on the servr),
yes?

As you mentioned that it works all ok on other clients, I think we can just
focus on the server's setting rather than the page code.
What's the FileType setting in the explorer's Folder Options? Is PDF
configured to always opened by the
"acrobat reader" ? Also, you can check whether there is advance setting
there which can set the default behavior for opening the pdf. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3

P: n/a
The pdf stream is opened correctly from my pc browser **if*** I run my web
app from a web server on our lan. If my pc browser opens same aspx page in
same web app but running on my pc's iis the pdf stream cannot be correctly
opened (it is opened by VS2003). Same web app...same client (my
workstation) only difference is running the web app local (iis on my pc) or
remotely (iis on server). PDF mime mapping is configured correctly (always
open with acrobat) and pdf file opens correctly when delivered from **any**
web site except my local pc and when local web app is rendering pdf content
in an aspx page; if my local iis delivers a .pdf file it
opens correctly.

Code snip

Select Case outputType
Case "doc"
contentType = "application/msword"
Case "xls"
contentType = "application/vnd.ms-excel"
Case "pdf"
contentType = "application/pdf"
End Select

With Current.Response
If System.IO.File.Exists(outputFile) = True Then
.ClearContent()
.ClearHeaders()
.ContentType = contentType
Dim fs As FileStream = New FileStream(outputFile, FileMode.Open)
Try
Dim bufferSize As Integer = CType(fs.Length, Integer)
Dim bt(bufferSize) As Byte
fs.Read(bt, 0, bufferSize)
.BinaryWrite(bt)
Catch ex As Exception
Finally
fs.Close()
End Try
.Flush()
.Close()
End If
End With

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:nx**************@cpmsftngxa10.phx.gbl...
Hi Brad,

From your description, you write down a pdf stream to the client browser.
However, currently, you found the pdf stream can be correctly opened in
acrobat reader at other remote clients but failed on local (on the servr),
yes?

As you mentioned that it works all ok on other clients, I think we can just focus on the server's setting rather than the page code.
What's the FileType setting in the explorer's Folder Options? Is PDF
configured to always opened by the
"acrobat reader" ? Also, you can check whether there is advance setting
there which can set the default behavior for opening the pdf. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx


Nov 18 '05 #4

P: n/a
Found the problem - HTTP compression was turned on for my local iis.
Appears that pdf content delivered by an aspx page does not work with that.
Turned compression off and everything works correctly.

"Brad" <no****@co.lane.or.us> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
The pdf stream is opened correctly from my pc browser **if*** I run my web
app from a web server on our lan. If my pc browser opens same aspx page in same web app but running on my pc's iis the pdf stream cannot be correctly
opened (it is opened by VS2003). Same web app...same client (my
workstation) only difference is running the web app local (iis on my pc) or remotely (iis on server). PDF mime mapping is configured correctly (always
open with acrobat) and pdf file opens correctly when delivered from **any** web site except my local pc and when local web app is rendering pdf content in an aspx page; if my local iis delivers a .pdf file it
opens correctly.

Code snip

Select Case outputType
Case "doc"
contentType = "application/msword"
Case "xls"
contentType = "application/vnd.ms-excel"
Case "pdf"
contentType = "application/pdf"
End Select

With Current.Response
If System.IO.File.Exists(outputFile) = True Then
.ClearContent()
.ClearHeaders()
.ContentType = contentType
Dim fs As FileStream = New FileStream(outputFile, FileMode.Open)
Try
Dim bufferSize As Integer = CType(fs.Length, Integer)
Dim bt(bufferSize) As Byte
fs.Read(bt, 0, bufferSize)
.BinaryWrite(bt)
Catch ex As Exception
Finally
fs.Close()
End Try
.Flush()
.Close()
End If
End With

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:nx**************@cpmsftngxa10.phx.gbl...
Hi Brad,

From your description, you write down a pdf stream to the client browser. However, currently, you found the pdf stream can be correctly opened in
acrobat reader at other remote clients but failed on local (on the servr), yes?

As you mentioned that it works all ok on other clients, I think we can

just
focus on the server's setting rather than the page code.
What's the FileType setting in the explorer's Folder Options? Is PDF
configured to always opened by the
"acrobat reader" ? Also, you can check whether there is advance setting
there which can set the default behavior for opening the pdf. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx


Nov 18 '05 #5

P: n/a
Hi Brad,

Thanks for your followup. Glad that you've figured out the problem.
Have a good day!

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.