PDF streaming

Discussion in 'ASP .Net' started by =?Utf-8?B?QW1hcg==?=, Aug 15, 2005.

  1. Hi,
    Could someone help me in pointing out what is wrong with this code? This
    works as expected in FireFox but not in IE. I have IE 6.0.
    I am trying to get a PDF which is hosted on our Intranet, and stream it out
    to the Internet users.

    Regards,
    Amar


    WebRequest myRequest = WebRequest.Create("http://intranet/amar/testform.pdf");

    WebResponse myResponse = myRequest.GetResponse();

    BinaryReader binReader = new BinaryReader(myResponse.GetResponseStream()) ;
    byte[] pdfByte =
    binReader.ReadBytes(Convert.ToInt32(myResponse.ContentLength));
    Response.Clear();
    Response.AddHeader("Content-Disposition","attachment;
    filename="+"test.pdf");
    Response.ContentType="application/pdf";
    Response.BinaryWrite(pdfByte);
    Response.Flush();
    Response.Close();
     
    =?Utf-8?B?QW1hcg==?=, Aug 15, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?QW1hcg==?=

    Andrea Zani Guest

    Amar <> ha scritto:
    > Hi,
    > Could someone help me in pointing out what is wrong with this code?
    > This works as expected in FireFox but not in IE. I have IE 6.0.
    > I am trying to get a PDF which is hosted on our Intranet, and stream
    > it out to the Internet users.
    >
    > Regards,
    > Amar


    Change the line:
    Response.AddHeader("Content-Disposition","attachment;
    filename="+"test.pdf");
    in:
    Response.AddHeader("Content-Disposition","inline;filename="+"test.pdf");

    --
    AZ [Microsoft - .NET MVP]
    Mia Home page: http://ciclismo.sitiasp.it
    Asp.Net community: http://www.aspitalia.com
    Il mio blog: http://blogs.aspitalia.com/az
     
    Andrea Zani, Aug 15, 2005
    #2
    1. Advertising

  3. Hi Andrea,
    Thanks for the reponse, but it did not work.
    Now it doesnt work on FireFox either.

    Amar


    "Andrea Zani" wrote:

    > Amar <> ha scritto:
    > > Hi,
    > > Could someone help me in pointing out what is wrong with this code?
    > > This works as expected in FireFox but not in IE. I have IE 6.0.
    > > I am trying to get a PDF which is hosted on our Intranet, and stream
    > > it out to the Internet users.
    > >
    > > Regards,
    > > Amar

    >
    > Change the line:
    > Response.AddHeader("Content-Disposition","attachment;
    > filename="+"test.pdf");
    > in:
    > Response.AddHeader("Content-Disposition","inline;filename="+"test.pdf");
    >
    > --
    > AZ [Microsoft - .NET MVP]
    > Mia Home page: http://ciclismo.sitiasp.it
    > Asp.Net community: http://www.aspitalia.com
    > Il mio blog: http://blogs.aspitalia.com/az
    >
    >
    >
     
    =?Utf-8?B?QW1hcg==?=, Aug 15, 2005
    #3
  4. =?Utf-8?B?QW1hcg==?=

    Andrea Zani Guest

    Amar <> ha scritto:
    > Hi Andrea,
    > Thanks for the reponse, but it did not work.
    > Now it doesnt work on FireFox either.
    >
    > Amar


    IE/FF show the message "Open" "Save"?

    If you write:
    Response.ContentType = "application/octet-stream"
    ?

    --
    AZ [Microsoft - .NET MVP]
    Mia Home page: http://ciclismo.sitiasp.it
    Asp.Net community: http://www.aspitalia.com
    Il mio blog: http://blogs.aspitalia.com/az
     
    Andrea Zani, Aug 15, 2005
    #4
  5. Hi Andrea,
    When I replaced “attachment†to “inline†it did not work when I typed the
    http://www.Internet.com/stream.aspx (stream.aspx contains the code mentioned
    earlier).
    Where as If I make http://www.Internet.com/stream.aspx as a link on some
    other page and then click the link, it works fine in both IE and FireFox.
    Any idea why?


    "Andrea Zani" wrote:

    > Amar <> ha scritto:
    > > Hi Andrea,
    > > Thanks for the reponse, but it did not work.
    > > Now it doesnt work on FireFox either.
    > >
    > > Amar

    >
    > IE/FF show the message "Open" "Save"?
    >
    > If you write:
    > Response.ContentType = "application/octet-stream"
    > ?
    >
    > --
    > AZ [Microsoft - .NET MVP]
    > Mia Home page: http://ciclismo.sitiasp.it
    > Asp.Net community: http://www.aspitalia.com
    > Il mio blog: http://blogs.aspitalia.com/az
    >
    >
    >
     
    =?Utf-8?B?QW1hcg==?=, Aug 15, 2005
    #5
  6. =?Utf-8?B?QW1hcg==?=

    Andrea Zani Guest

    Amar <> ha scritto:
    > Hi Andrea,
    > When I replaced "attachment" to "inline" it did not work when I typed
    > the http://www.Internet.com/stream.aspx (stream.aspx contains the
    > code mentioned earlier).
    > Where as If I make http://www.Internet.com/stream.aspx as a link on
    > some other page and then click the link, it works fine in both IE and
    > FireFox. Any idea why?


    With IE6.0 and SP?

    --
    AZ [Microsoft - .NET MVP]
    Mia Home page: http://ciclismo.sitiasp.it
    Asp.Net community: http://www.aspitalia.com
    Il mio blog: http://blogs.aspitalia.com/az
     
    Andrea Zani, Aug 15, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Wallace
    Replies:
    0
    Views:
    1,067
    James Wallace
    Oct 17, 2003
  2. Hans Kesting

    Re: Streaming PDF to Browser from Server

    Hans Kesting, Jan 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    384
    Hans Kesting
    Jan 9, 2004
  3. Jerry Boone

    Re: Streaming PDF to Browser from Server

    Jerry Boone, Jan 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,008
    Jerry Boone
    Jan 9, 2004
  4. Ricardo Pog
    Replies:
    1
    Views:
    445
    Austin Ziegler
    Mar 26, 2008
  5. Sean Nakasone
    Replies:
    1
    Views:
    392
    Farrel Lifson
    Apr 14, 2008
Loading...

Share This Page