473,320 Members | 1,958 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,320 software developers and data experts.

Streaming PDF to Browser from Server

Rob
I have an ASP.Net web app that generates a Crystal Report in PDF format.
Since there is sensitive data within the reports, the pdfs need to be
streamed to the browser then deleted immediately. The report gets kick off
by a Java application redirecting the URL to the ASP.Net app on the IIS
Server with all report selection criteria appended to the querystring. The
Crystal Report is rendered in a new window.

In the Page_Load() event, I pull down all of the querystring parameter
values, use the values to query the database, return a dataset, generate a
Crystal Report in PDF Format, stream the PDF to the browser, then delete the
PDF. This works all fine and dandy, but the Page_Load() event gets executed
twice, so everything previously stated gets executed again. I am using IE
5.5. This issue is covered by Microsoft Article 307603.

http://support.microsoft.com/default.aspx?kbid=307603

What I was wondering is if any other developers have experienced this same
issue and what type of coding techniques were used to get around querying
the database twice and only streaming and deleting the PDF once?

If you have a PDF file, execute the following code below and put a
breakpoint in the code. You will see that this event is executed 2 or 3
times, depending on the version of your browser. No postbacks are made.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Query Database Code
...

'Generate Crystal Report in PDF Format
...

'Stream PDF to Browser
'Set the appropriate ContentType.
Response.ContentType = "Application/pdf"
'Get the physical path to the file.
Dim FilePath As String = MapPath("acrobat.pdf")
'Write the file directly to the HTTP output stream.
Response.WriteFile(FilePath)
Response.End()

End Sub
Any help or comments are appreciated.

Thanks,
Rob
Nov 18 '05 #1
3 6202
To get around the "page loading twice issue" I redirect the user to a PDF
stored on disk. That seems to solve that problem, but doesn't solve the
"PDF must be deleted immediatly" problem.

Maybe you can have a Service that checks that directory and deletes any
files older than X (maybe one minute)?
"Rob" <rw****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have an ASP.Net web app that generates a Crystal Report in PDF format.
Since there is sensitive data within the reports, the pdfs need to be
streamed to the browser then deleted immediately. The report gets kick off by a Java application redirecting the URL to the ASP.Net app on the IIS
Server with all report selection criteria appended to the querystring. The Crystal Report is rendered in a new window.

In the Page_Load() event, I pull down all of the querystring parameter
values, use the values to query the database, return a dataset, generate a
Crystal Report in PDF Format, stream the PDF to the browser, then delete the PDF. This works all fine and dandy, but the Page_Load() event gets executed twice, so everything previously stated gets executed again. I am using IE
5.5. This issue is covered by Microsoft Article 307603.

http://support.microsoft.com/default.aspx?kbid=307603

What I was wondering is if any other developers have experienced this same
issue and what type of coding techniques were used to get around querying
the database twice and only streaming and deleting the PDF once?

If you have a PDF file, execute the following code below and put a
breakpoint in the code. You will see that this event is executed 2 or 3
times, depending on the version of your browser. No postbacks are made.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Query Database Code
...

'Generate Crystal Report in PDF Format
...

'Stream PDF to Browser
'Set the appropriate ContentType.
Response.ContentType = "Application/pdf"
'Get the physical path to the file.
Dim FilePath As String = MapPath("acrobat.pdf")
'Write the file directly to the HTTP output stream.
Response.WriteFile(FilePath)
Response.End()

End Sub
Any help or comments are appreciated.

Thanks,
Rob

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.559 / Virus Database: 351 - Release Date: 1/7/2004
Nov 18 '05 #2

"Rob" <rw****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
In the Page_Load() event, I pull down all of the querystring parameter
values, use the values to query the database, return a dataset, generate a
Crystal Report in PDF Format, stream the PDF to the browser, then delete the PDF. This works all fine and dandy, but the Page_Load() event gets executed twice, so everything previously stated gets executed again. [snip] Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

[snip]

What probably happens: in vb.net there is a feature that automatically
connects
events to methods. A method with the name Page_Load is then automatically
connected to the Load event of the Page.
In this case you also specify that connection explicitly (Handles ..), so
the method
is connected twice, and thus fired twice.

Solution: either switch that autoconnect feature off, or remove the
"handles" clause.
Hans Kesting
Nov 18 '05 #3
I don't think your going to get around the problem of having the PDF not
accessible by the client for saving locally.

But... what about making your report a web service? I haven't done it yet
but from what I understand... you can right click and "Publish as web
service", then build a small little windows application that includes the cr
viewer and a reference to the web service. It might possibly give you the
control your seek... even the ability to deny printing the report.

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access
"Rob" <rw****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have an ASP.Net web app that generates a Crystal Report in PDF format.
Since there is sensitive data within the reports, the pdfs need to be
streamed to the browser then deleted immediately. The report gets kick off by a Java application redirecting the URL to the ASP.Net app on the IIS
Server with all report selection criteria appended to the querystring. The Crystal Report is rendered in a new window.

In the Page_Load() event, I pull down all of the querystring parameter
values, use the values to query the database, return a dataset, generate a
Crystal Report in PDF Format, stream the PDF to the browser, then delete the PDF. This works all fine and dandy, but the Page_Load() event gets executed twice, so everything previously stated gets executed again. I am using IE
5.5. This issue is covered by Microsoft Article 307603.

http://support.microsoft.com/default.aspx?kbid=307603

What I was wondering is if any other developers have experienced this same
issue and what type of coding techniques were used to get around querying
the database twice and only streaming and deleting the PDF once?

If you have a PDF file, execute the following code below and put a
breakpoint in the code. You will see that this event is executed 2 or 3
times, depending on the version of your browser. No postbacks are made.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Query Database Code
...

'Generate Crystal Report in PDF Format
...

'Stream PDF to Browser
'Set the appropriate ContentType.
Response.ContentType = "Application/pdf"
'Get the physical path to the file.
Dim FilePath As String = MapPath("acrobat.pdf")
'Write the file directly to the HTTP output stream.
Response.WriteFile(FilePath)
Response.End()

End Sub
Any help or comments are appreciated.

Thanks,
Rob

Nov 18 '05 #4

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

Similar topics

2
by: 11abacus | last post by:
Hi all, I wonder if this is possible: I have a script that does things that take time. In the first part of the script it does data checking and other verifications, then comes the long part. I...
12
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank,...
1
by: Chris Davoli | last post by:
I'm getting these errors: IN VS.NET: The web server reported the following error when attempting to create or open the web project located at the following URL:...
3
by: tom | last post by:
I need a C#, peer-to-peer solution for streaming video from a webcam on one box to a client application on the other box. Can someone please help me with this? I can read video from a webcam easy...
3
by: David Walker | last post by:
Hi, I've encountered a problem when installing the .Net framework version 1.0 on a Windows 2000 Server machine in a clustered environment. After I install the framework and try to run a simple...
0
by: Julia999 | last post by:
I run my web page from .net, is good, in localhost -http://localhost:3457/IFWebSerivce/TestIProvision.aspx but set the virtual dir in IIS and want to run from browser/server, ...
9
by: jazzslider | last post by:
I have a headache. I've done a LOT of research lately into XForms, and I am thoroughly convinced that a good implementation of this technology would help me immensely in converting my...
13
dmjpro
by: dmjpro | last post by:
i didn't find any place in this site to send my question.... that's why i am here does browser send any info about .... the userAgent is cookie enabled or not
8
by: Tony K | last post by:
Is streaming audio capable in asp.net 2.0 / AJAX? What I mean by streaming audio is: ability to play one or more songs back to back...or maybe even let the user select several songs to play and it...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.