Response.BinaryWrite or something causes multiple posts

From: Dan C (DanC_at_discussions.microsoft.com)
Date: 08/19/04


Date: Thu, 19 Aug 2004 13:03:02 -0700

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)
  • 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: Display byte array back to pdf and display in IE
    ... >PDF never gets displayed in browser ... The request contains a list of the sort of responses it is prepared to ... If an Applet, ...
    (comp.lang.java.programmer)
  • RE: Response.BinaryWrite or something causes multiple posts
    ... Their problem has to do with a "post" to the server and SSL. ... When the user selected to print the report, I had to put the selection ... page used the selection criteria in the session variable to generate the PDF. ... the first request, I assume, works fine. ...
    (microsoft.public.dotnet.framework.aspnet)