473,394 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

sending pdf content to the browser

I have pdf files stored in a database image field. I need an aspx page that
will send the pdf to the browser. The code I have (in the page_load event)
works the first time I run it:

[code to query database and put pdf contents into bytearray ba, with length
K omitted]
Response.ContentType = "application/pdf"
Response.Clear()
Response.OutputStream.Write(ba, 0, K)
Response.End()

The first time I run the page, I see the pdf in the browser, as I wish. When
I refresh the page (or change the querystring parameter), I get a white blank
screen in my web browser. I don't know what the browser is doing (IE 6.0).
If I right-click the browser screen and select "View Source", I get a message
from IE "The XML source file is unavailable for viewing".

I also get the following message in the Immediate Window when the
Response.End is executed: "A first chance exception of type
'System.Threading.ThreadAbortException' occurred in mscorlib.dll. An
exception of type 'System.Threading.ThreadAbortException' occurred in
mscorlib.dll but was not handled in user code".

Any clues as how to debug this? Someone else wrote that the above error can
be ignored because it is always generated on Response.End. Is that true? I
don't think this is a caching problem because if I put a debug breakpoint in
the page_load event, the code appears to execute correctly (until it gets to
the response.end).

Joel

Apr 26 '06 #1
3 3731
Try Response.Flush() before Response.End

Cheers,

Greg
"Joel H" <Jo***@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.com...
I have pdf files stored in a database image field. I need an aspx page
that
will send the pdf to the browser. The code I have (in the page_load
event)
works the first time I run it:

[code to query database and put pdf contents into bytearray ba, with
length
K omitted]
Response.ContentType = "application/pdf"
Response.Clear()
Response.OutputStream.Write(ba, 0, K)
Response.End()

The first time I run the page, I see the pdf in the browser, as I wish.
When
I refresh the page (or change the querystring parameter), I get a white
blank
screen in my web browser. I don't know what the browser is doing (IE
6.0).
If I right-click the browser screen and select "View Source", I get a
message
from IE "The XML source file is unavailable for viewing".

I also get the following message in the Immediate Window when the
Response.End is executed: "A first chance exception of type
'System.Threading.ThreadAbortException' occurred in mscorlib.dll. An
exception of type 'System.Threading.ThreadAbortException' occurred in
mscorlib.dll but was not handled in user code".

Any clues as how to debug this? Someone else wrote that the above error
can
be ignored because it is always generated on Response.End. Is that true?
I
don't think this is a caching problem because if I put a debug breakpoint
in
the page_load event, the code appears to execute correctly (until it gets
to
the response.end).

Joel

Apr 26 '06 #2
Thanks for the reply, but it didn't help.

"Greg Young [MVP]" wrote:
Try Response.Flush() before Response.End

Cheers,

Greg
"Joel H" <Jo***@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.com...
I have pdf files stored in a database image field. I need an aspx page
that
will send the pdf to the browser. The code I have (in the page_load
event)
works the first time I run it:

[code to query database and put pdf contents into bytearray ba, with
length
K omitted]
Response.ContentType = "application/pdf"
Response.Clear()
Response.OutputStream.Write(ba, 0, K)
Response.End()

The first time I run the page, I see the pdf in the browser, as I wish.
When
I refresh the page (or change the querystring parameter), I get a white
blank
screen in my web browser. I don't know what the browser is doing (IE
6.0).
If I right-click the browser screen and select "View Source", I get a
message
from IE "The XML source file is unavailable for viewing".

I also get the following message in the Immediate Window when the
Response.End is executed: "A first chance exception of type
'System.Threading.ThreadAbortException' occurred in mscorlib.dll. An
exception of type 'System.Threading.ThreadAbortException' occurred in
mscorlib.dll but was not handled in user code".

Any clues as how to debug this? Someone else wrote that the above error
can
be ignored because it is always generated on Response.End. Is that true?
I
don't think this is a caching problem because if I put a debug breakpoint
in
the page_load event, the code appears to execute correctly (until it gets
to
the response.end).

Joel


Apr 26 '06 #3
I think I found a workaround. According to this page:
http://forums.microsoft.com/MSDN/Sho...29441&SiteID=1
Installation of Visual Studio causes the problem. If I simply add another
parameter to the querystring like "&dummy=x.pdf", the problem disappears.

Joel

"Joel H" wrote:
Thanks for the reply, but it didn't help.

"Greg Young [MVP]" wrote:
Try Response.Flush() before Response.End

Cheers,

Greg
"Joel H" <Jo***@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.com...
I have pdf files stored in a database image field. I need an aspx page
that
will send the pdf to the browser. The code I have (in the page_load
event)
works the first time I run it:

[code to query database and put pdf contents into bytearray ba, with
length
K omitted]
Response.ContentType = "application/pdf"
Response.Clear()
Response.OutputStream.Write(ba, 0, K)
Response.End()

The first time I run the page, I see the pdf in the browser, as I wish.
When
I refresh the page (or change the querystring parameter), I get a white
blank
screen in my web browser. I don't know what the browser is doing (IE
6.0).
If I right-click the browser screen and select "View Source", I get a
message
from IE "The XML source file is unavailable for viewing".

I also get the following message in the Immediate Window when the
Response.End is executed: "A first chance exception of type
'System.Threading.ThreadAbortException' occurred in mscorlib.dll. An
exception of type 'System.Threading.ThreadAbortException' occurred in
mscorlib.dll but was not handled in user code".

Any clues as how to debug this? Someone else wrote that the above error
can
be ignored because it is always generated on Response.End. Is that true?
I
don't think this is a caching problem because if I put a debug breakpoint
in
the page_load event, the code appears to execute correctly (until it gets
to
the response.end).

Joel


Apr 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Kubaton Lover | last post by:
I have a pdf file (syllabus.pdf) on the server. I have written the following PHP code. It correctly finds the file, but it is sending the file back as text I think because I'm seeing the binary...
9
by: Gregor Rot | last post by:
Hi, i am sending a pdf file to IE6 and just want the browser to open it directly without asking anything. This doesn't work: Content-type: application/pdf Content-length: size_of_file...
3
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt....
2
by: Frostillicus | last post by:
I'm trying to get an ASP to return a zip file to the remote browser from an Image (BLOB) field in SQL Server 2000 but Internet Explorer keeps saying: Cannot open C:\Documents and...
1
by: Butch | last post by:
Hi, I won't lie to you. I'm trying to get data from html source from a 3rd party website. I'm NOT interested in stealing code,hacking,sending spam or anything sinister like that. I just want the...
20
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to...
7
by: Jay Douglas | last post by:
Hello all, I have a asp.net page that creates a pdf on the fly and sends the pdf down to the browser. When calling the page up in IE the Page_Load event is fried twice. This doesn't happen with...
5
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I...
4
by: splicemix | last post by:
Hi all, I have recently set up a Drupal website. I am a beginner. My shared host server does not allow nobody@localhost to send emails, and prevents access to php.ini, so I spent some time...
20
by: Tony | last post by:
I have a situation where I want to send data, but I have no need for a response. It seems to me that XMLHTTPRequest is the best way to send the data, but I don't need any response back from the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.