Display Image Binary data in Web Browser

Discussion in 'ASP .Net Web Services' started by klj_mcsd@hotmail.com, Jul 11, 2005.

  1. Guest

    I'm returning the binary data from my webservice and it works but I'm
    having problems rendering the image in an <img> tag in my web browser.
    The code I'm using is below:


    Dim wsurl
    wsurl = "http://localhost/wsImage/wsImage.asmx/GetImage?sSpecNo=" & "1"
    Dim xmlhttp
    Set xmlhttp=Server.CreateObject("MSXML2.ServerXMLHTTP")xmlhttp.open
    "GET",wsurl,false
    xmlhttp.send
    Response.ContentType = "image/png"
    Response.BinaryWrite xmlhttp.responsebody
    Set xmlhttp=nothing
    Response.End

    I am calling this code from my image tag
     
    , Jul 11, 2005
    #1
    1. Advertising

  2. One way to do is is mage the img src point to an ASPX page that outouts
    the binary. Does this answer your question?
     
    Keenan Newton, Jul 12, 2005
    #2
    1. Advertising

  3. Pete Wood Guest

    Yes its a problem. You can construct an ASPX page with a graphic <IMG> with
    src= "/images/mydownload.jpg". You can then write the binary data to the
    exact same file location, and over-ride the "dummy" file that was there
    already. I have an example somewhere, so let me know if this isn't clear
    and I'll dig it out for you - it may take a while!
    --
    Pete Wood
    Contact me at http://www.webserviceshelp.org for more help
    _________________________________________________________


    <> wrote in message
    news:...
    > I'm returning the binary data from my webservice and it works but I'm
    > having problems rendering the image in an <img> tag in my web browser.
    > The code I'm using is below:
    >
    >
    > Dim wsurl
    > wsurl = "http://localhost/wsImage/wsImage.asmx/GetImage?sSpecNo=" & "1"
    > Dim xmlhttp
    > Set xmlhttp=Server.CreateObject("MSXML2.ServerXMLHTTP")xmlhttp.open
    > "GET",wsurl,false
    > xmlhttp.send
    > Response.ContentType = "image/png"
    > Response.BinaryWrite xmlhttp.responsebody
    > Set xmlhttp=nothing
    > Response.End
    >
    > I am calling this code from my image tag
    >
     
    Pete Wood, Jul 15, 2005
    #3
    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. Denise Smith
    Replies:
    2
    Views:
    668
    Denise Smith
    Nov 22, 2003
  2. =?Utf-8?B?c2NvdHRybQ==?=

    retrieve binary data from database and display in browser

    =?Utf-8?B?c2NvdHRybQ==?=, Mar 23, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    733
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Mar 23, 2007
  3. Holysmoke
    Replies:
    0
    Views:
    137
    Holysmoke
    Nov 16, 2005
  4. amita
    Replies:
    0
    Views:
    222
    amita
    Aug 18, 2003
  5. Jack
    Replies:
    2
    Views:
    237
    John W. Krahn
    Jan 25, 2008
Loading...

Share This Page