Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Response.BinaryWrite question, please

Reply
Thread Tools

Response.BinaryWrite question, please

 
 
Alex Nitulescu
Guest
Posts: n/a
 
      02-15-2005
Hi. I have a WebService which provides a webmethod which returns a byte
array representing a picture. The method's signature is:

<WebMethod(Description:="Shows something nice every time !")> Public
Function GetRandomImage() As Byte()

I then have a test application (with a web reference to my web service)
which has the following code:

Public Class BinaryWebServiceTest
Inherits System.Web.UI.Page
Protected WithEvents lblResults As System.Web.UI.WebControls.Label

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim objBinaryWebService As New localhost.ImagesWebService()

Response.Clear()
Response.ClearHeaders()
Response.ContentType = "image/jpeg"
Response.BinaryWrite(objBinaryWebService.GetRandom Image)
objBinaryWebService.Dispose()
End Sub
End Class

That's all, and it works fine, except.... I have controls on my test form. I
also have set a bgColor of my page, a custom header, footer, and so on.
However, when I call "response.BinaryWrite" they all vanish (or is it
because of "Response.ContentType" ???) - the random pictures I'm showing
look just fine, but I need to paint them differently, so as to be able to
see the rest of the contents of my page. What are my options, please ?

Thank you, Alex.

PS. Yes, I *could* use a Image control and in the web service manufacture a
random NavigateURL from my "Pictures" directory, but what If I need to
transmit images instead of links ?


 
Reply With Quote
 
 
 
 
William F. Robertson, Jr.
Guest
Posts: n/a
 
      02-15-2005
You options are to use a http handler and have the handler make the
connection to your webservice. You can not encode more than one content
type in an html page. When this page is loading, you are changing the
content type to image, and then sending the binary data for this one image.
The browser is simply ignoring the rest of it.

http://msdn.microsoft.com/msdnmag/is...e/default.aspx

You will use a http handler for the image. The resulting html will look
something like <img src="imageHandler.axd">

HTH,

bill

"Alex Nitulescu" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi. I have a WebService which provides a webmethod which returns a byte
> array representing a picture. The method's signature is:
>
> <WebMethod(Description:="Shows something nice every time !")> Public
> Function GetRandomImage() As Byte()
>
> I then have a test application (with a web reference to my web service)
> which has the following code:
>
> Public Class BinaryWebServiceTest
> Inherits System.Web.UI.Page
> Protected WithEvents lblResults As System.Web.UI.WebControls.Label
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> Dim objBinaryWebService As New localhost.ImagesWebService()
>
> Response.Clear()
> Response.ClearHeaders()
> Response.ContentType = "image/jpeg"
> Response.BinaryWrite(objBinaryWebService.GetRandom Image)
> objBinaryWebService.Dispose()
> End Sub
> End Class
>
> That's all, and it works fine, except.... I have controls on my test form.

I
> also have set a bgColor of my page, a custom header, footer, and so on.
> However, when I call "response.BinaryWrite" they all vanish (or is it
> because of "Response.ContentType" ???) - the random pictures I'm showing
> look just fine, but I need to paint them differently, so as to be able to
> see the rest of the contents of my page. What are my options, please ?
>
> Thank you, Alex.
>
> PS. Yes, I *could* use a Image control and in the web service manufacture

a
> random NavigateURL from my "Pictures" directory, but what If I need to
> transmit images instead of links ?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please please please help this guy with his open source java app casioculture@gmail.com Java 4 05-05-2005 08:24 AM
Console profile for Windows app in VC++ - PLEASE PLEASE PLEASE HELP! MuZZy C++ 7 01-07-2005 08:40 PM
Computer problems please please please help Nick Computer Support 0 06-04-2004 08:49 PM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments