Issue using Binarywrite on IE6/7

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amollokhande1
    New Member
    • Feb 2008
    • 33

    Issue using Binarywrite on IE6/7

    Hi All,

    I am writting the the pdf data to the browser by using following code in vb.Net application

    Response.Clear( )
    Response.Conten tType = "Applicatio n/pdf"
    Response.Binary Write(buffer)
    Response.End()

    Above code worked fine on Firefox i.e pdf file gets shown on the browser properly.

    But the same code is not working on IE 6/7. I am getting following error when I try to use the pdf application on IE.

    "Internet Explorer cannot download PDF.aspx from localhost.
    Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
    "

    I have also installed the acrobat reader on the same m/c but still it showing me above error.

    Can anybody have the solution to resolve this issue?




    Regards
    Amol Lokhande
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Why not use Response.WriteF ile(filename); ?

    If you want to use the BinaryWrite() function, you will need to set the content length right?

    Comment

    • amollokhande1
      New Member
      • Feb 2008
      • 33

      #3
      Hi Plater,

      Actually I am getting the output in the binary format, which when write to browser, it displays the pdf file in the browser. As per your suggestion, I have added length of buffer as well. but it is showing the same error. Is it something related to security on browser.

      Regards
      Amol Lokhande

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Have you tried messing about with the cache control headers? I had some troubles with cache settings when I was doing roughly the same thing.

        Comment

        • amollokhande1
          New Member
          • Feb 2008
          • 33

          #5
          Hi Plater,

          Thanks for your support. I have added following code

          Response.Buffer = True
          Response.Expire s = 0
          Response.Conten tType = "applicatio n/pdf"
          Response.AddHea der("Content-Type", "applicatio n/pdf")
          Response.AddHea der("Content-Length", buffer.Length.T oString)
          Response.AddHea der("Content-Disposition", "inline;filenam e=new.pdf")
          Response.Cache. SetCacheability (HttpCacheabili ty.NoCache)
          Response.Binary Write(buffer)
          Response.End()

          And it worked. But the issue here is that this works only on IE7. I am not able to identify the cause why it is not working in IE6.

          Regards
          Amol Lokhande

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            What happens when you choose to SAVE the file instead of open it in IE6?
            Maybe once you save it, open up in a text viewer (notepad.exe) and see if there is some http breadcrumbs in there?

            Comment

            • amollokhande1
              New Member
              • Feb 2008
              • 33

              #7
              Hi Plater,

              That code also worked on IE6. Actually I mess up with setting on IE6

              Regards
              Amol Lokhande

              Comment

              Working...