473,624 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Response.Binary Write 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(Desc ription:="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 BinaryWebServic eTest
Inherits System.Web.UI.P age
Protected WithEvents lblResults As System.Web.UI.W ebControls.Labe l

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

Dim objBinaryWebSer vice As New localhost.Image sWebService()

Response.Clear( )
Response.ClearH eaders()
Response.Conten tType = "image/jpeg"
Response.Binary Write(objBinary WebService.GetR andomImage)
objBinaryWebSer vice.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.Binar yWrite" they all vanish (or is it
because of "Response.Conte ntType" ???) - 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 2769
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="imageHandl er.axd">

HTH,

bill

"Alex Nitulescu" <RE************ ***********@yah oo.com> wrote in message
news:uV******** ******@TK2MSFTN GP09.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(Desc ription:="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 BinaryWebServic eTest
Inherits System.Web.UI.P age
Protected WithEvents lblResults As System.Web.UI.W ebControls.Labe l

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

Dim objBinaryWebSer vice As New localhost.Image sWebService()

Response.Clear( )
Response.ClearH eaders()
Response.Conten tType = "image/jpeg"
Response.Binary Write(objBinary WebService.GetR andomImage)
objBinaryWebSer vice.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.Binar yWrite" they all vanish (or is it
because of "Response.Conte ntType" ???) - 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
7191
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 Megabyte -- w3wp.exe eat all memory (I have 1024 megabytes) and all CPU time without positive result.
5
17874
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"? <%@ Language=VBScript %> <% Response.Buffer = TRUE Response.ContentType = "image/jpg"
3
7576
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 : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { Byte myPdf = GetPdf();
2
1927
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. I'm sending the file to the client in 4 KB chunks. Sending the file works fine, but when I click a link on the calling aspx-Page ("ShowListOfFiles.aspx") after the download completed, the browser window shows fragments of the recently transmitted...
11
26834
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 follows: private void SubmitButton_Click (object sender, System.EventArgs e) { // Set up the response to write the print file to the client Response.Clear (); Response.AppendHeader ("Content-Disposition", "filename=WebPrint.prn");
0
306
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 !")> 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
2
2039
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 something like this: ========================================== <%@ Language=VBScript %> <%
1
4209
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 very simple, there is a folder of files with numeric names. The real file name is stored in the database. User clicks on link that executes script and provides database record id. Record is looked up, file name is found, and browser is delivered...
1
6276
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", "attachment;filename="& file & ";" Set objStream = Server.CreateObject("ADODB.Stream") objStream.Open
0
8672
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8330
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8471
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2603
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.