473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Response.BinaryWrite question, please

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 ?
Nov 19 '05 #1
1 2739
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" <RE***********************@yahoo.com> wrote in message
news:uV**************@TK2MSFTNGP09.phx.gbl...
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 ?

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Zam | last post by:
Hello World, Under Windows 2003 Server. IIS6. The following code working fine for small files, and for files with size about few megabytes. If I am trying to send HUGE file -- about 700...
5
by: katrinaVictim | last post by:
Question: I get the eror listed at the bottom of the post. What can I do to make the response of the x1.send a "binary" type? Or, in general, how can I just "make this work"? <%@...
3
by: spmm# | last post by:
Hi! My ASP.NET page gets a pdf-file from a SQLServer database and writes it in a browserwindow, using Response.BinaryWrite. It basically looks like this: public class WebForm1 :...
2
by: hoenes1 | last post by:
I've got an aspx-Page "SendFile.aspx" which is called by a Link on "ShowListOfFiles.aspx" and sends the file in the OnLoad Eventhandler. The filename to download is stored in a Session variable....
11
by: Russ | last post by:
My web app writes some binary data to a file at the client site via Response.Write and Response.BinaryWrite. This action is accomplished in response to a button click, with C# code behind as...
0
by: Alex Nitulescu | last post by:
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 !")>...
2
by: ATS | last post by:
HOWTO Override ASP's Response output for 2003/IIS. Please help, I want to have an ASP page write back EVERYTHING to the ASP Response. That includes HTTP Headers. I want my ASP to look...
1
by: mattridings | last post by:
Hi gang, Have a script that works fine. However, it's really cpu intensive and I'm looking for suggestions on a) whether or not that's normal and if so b)a better way of doing it. Script is...
1
by: .nLL | last post by:
hi everyone. i use asp to send files to users to prevent hotlinking and i always used following code Response.ContentType="video/3gpp" response.addheader "Content-Disposition",...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.