RE: Response.BinaryWrite or something causes multiple posts

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Brad Roberts (BradRoberts_at_discussions.microsoft.com)
Date: 08/19/04


Date: Thu, 19 Aug 2004 15:03:03 -0700

I have had some problems with the DynamicPDF and had had to do something
similar. Their problem only occurs with SSL. In the development environment I
had no problem. Their problem has to do with a "post" to the server and SSL.

I have a report-selection-criteria page that initiates the creation of the
PDF. When the user selected to print the report, I had to put the selection
criteria in a session variable, redisplay the selection page, and open up
another window (which is a GET) using another ASPX page in the URL. This new
page used the selection criteria in the session variable to generate the PDF.
This avoided creating a PDF file anywhere that would need to be cleaned up.
Also, I had to append a date-time-stamp to the URL to make it unique so the
user's browser would not cache it.

In all this I also discovered a documented problem where "content expiration
immediately" set on the IIS server that caused a problem with Office
documents also affected PDF documents. I can go into that if needed...

Hope this helps.

"Dan C" wrote:

> I think this is probably going to be an obscure problem nobody has seen, but
> I'll give it a shot.
>
> I have two pages in a system. the first:
> 1) queries a database and builds a pdf file using a third party control
> 2) writes the pdf to a file
> 3) redirects to the second page.
>
> the second page
> 1) reads the file written by the first page in to a FileStream
> 2) writes the contents to a byte array
> 3) Response.BinaryWrite's the byte array
> 4) File.Delete's the file
>
> the reason I am doing it this way are that the third-party pdf generator
> causes a security warning when trying to write directly to the response
> stream, but I don't want the file sitting around forever. I know there are
> other ways, but I want to know why this particular one won't work.
>
> there are two ways the first page is accessed, through a Response.Redirect,
> and through an html anchor with a target of "_blank". when the browser
> navigates to the first page through the Redirect, everything works
> beautifully. the first page writes the pdf, the second page reads it, writes
> the contents, and deletes it without any problems.
>
> however, when the first page is accessed through an anchor with the _blank
> target, there are problems because, somehow, two http requests are generated
> for the second page. the first request, I assume, works fine. the pdf file
> does get read and deleted. but somewhere in the process, the browser issues
> another request, and since the file has been deleted by the first request,
> the page doesn't work. the second request does not have the http_referrer set
> in the post, and it is not a post back.
>
> does that make sense to anybody? and why would that happen?
>
> thanks for any insight you might have!



Relevant Pages

  • Re: detecting the session closing
    ... Russell, sounds like you're trying to construct a simple, secure document ... "heartbeat" between the client and the server. ... On a request for the document (which, I'm guessing, is a special ... > closing so I can delete the pdf file. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Response.BinaryWrite or something causes multiple posts
    ... queries a database and builds a pdf file using a third party control ... and through an html anchor with a target of "_blank". ... the first request, I assume, works fine. ... the browser issues ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Response.BinaryWrite or something causes multiple posts
    ... > 1) queries a database and builds a pdf file using a third party control ... > 3) redirects to the second page. ... > 3) Response.BinaryWrite's the byte array ... the first request, I assume, works fine. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Response.BinaryWrite or something causes multiple posts
    ... > 1) queries a database and builds a pdf file using a third party control ... > 3) redirects to the second page. ... > 3) Response.BinaryWrite's the byte array ... the first request, I assume, works fine. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Making PDF files for large number of WORD Docs
    ... It sounds as though you have used the same directory selection. ... Dim sPrinter As String ... If you use the Adobe, File, Create PDF, from Multiple Documents, ...
    (microsoft.public.word.newusers)