Problem opening PDF file written to browser

B

Brad

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
 
L

Lucas Tam

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?
 
S

Steven Cheng[MSFT]

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
 
B

Brad

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
 
B

Brad

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top