473,569 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) Handles MyBase.Load

'Query Database Code
...

'Generate Crystal Report in PDF Format
...

'Stream PDF to Browser
'Set the appropriate ContentType.
Response.Conten tType = "Applicatio n/pdf"
'Get the physical path to the file.
Dim FilePath As String = MapPath("acroba t.pdf")
'Write the file directly to the HTTP output stream.
Response.WriteF ile(FilePath)
Response.End()

End Sub
Any help or comments are appreciated.

Thanks,
Rob
Nov 18 '05 #1
3 6212
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******** ********@TK2MSF TNGP10.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.EventArg s) Handles MyBase.Load

'Query Database Code
...

'Generate Crystal Report in PDF Format
...

'Stream PDF to Browser
'Set the appropriate ContentType.
Response.Conten tType = "Applicatio n/pdf"
'Get the physical path to the file.
Dim FilePath As String = MapPath("acroba t.pdf")
'Write the file directly to the HTTP output stream.
Response.WriteF ile(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******** ********@TK2MSF TNGP10.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.EventArg s) 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******** ********@TK2MSF TNGP10.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.EventArg s) Handles MyBase.Load

'Query Database Code
...

'Generate Crystal Report in PDF Format
...

'Stream PDF to Browser
'Set the appropriate ContentType.
Response.Conten tType = "Applicatio n/pdf"
'Get the physical path to the file.
Dim FilePath As String = MapPath("acroba t.pdf")
'Write the file directly to the HTTP output stream.
Response.WriteF ile(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
4245
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 wish to be able to send the result of the first part to the client, disconnect the HTTP (so the client can do whatever they want), the script should...
12
12406
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, 'height=200,width=400,status=no,toolbar=no, menubar=no,location=no resizable=no scrollable=no'); but I can't seem to invoke the client side script from within a Server...
1
1109
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: 'http://localhost/webapplication1. 'HTTP/1.1 500 Internal Server Error'. IN BROWSER: Server Application Unavailable The web application you are attempting to access on this web...
3
9540
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 enough but streaming the feed to a client application seems to be a different story Any help would be appreciated Thanks in advance Tom
3
2130
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 ASP.Net web page I receive the following message in my web browser: "Server Application Unavailable The web application you are attempting to access...
0
1240
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, http://ofacbr.worldnet-dev.ml.com/brrlsu/WebServiceCall/IFWebSerivce/TestIProvision.aspx I got error - Server Error in '/BRRLSU' Application....
9
2371
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 department's paper forms into interactive online systems. There are a couple of problems I'm facing that I'm hoping someone here could help with. Number...
13
1396
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
3087
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 will play them back to back. Thanks, Tony K
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.