473,769 Members | 8,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BinaryWrite or OutputStream.Wr ite

The goal here is to return a dynamic image from an HttpHandler that I have
written. 2 questions

1. I am reading the images into byte[] fine and cacheing them fine, but what
should I use to deliver the image to the client?
My code:

context.Respons e.ContentType = "image/gif";
context.Respons e.Cache.SetCach eability(HttpCa cheability.NoCa che);
context.Respons e.Cache.SetNoSt ore();
context.Respons e.Cache.SetExpi res(DateTime.Mi nValue);
context.Respons e.BufferOutput = false;
context.Respons e.BinaryWrite(i mageBytes);

or should the last line be:
context.Respons e.OutputStream. Write(imageByte s, 0, imageBytes.Leng th);

2. Should I do something like this:

context.Respons e.AddHeader("Co ntent-Disposition","i nline;filename= random.gif");

Feb 10 '06 #1
2 8378
I wouldn't add the Content-Disposition header as this may prompt the
user to save or open the image file. You already set the ContentType to
an image type.

As for BinaryWrite or OutputStream.Wr ite, I prefer BinaryWrite as a
short hand method. Under the covers, BinaryWrite most likely calls
Response.Output Steam.Write

Feb 10 '06 #2
You were correct:

From Reflector:

public void BinaryWrite(byt e[] buffer)
{
this.OutputStre am.Write(buffer , 0, buffer.Length);
}
Feb 12 '06 #3

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

Similar topics

6
7854
by: Richard | last post by:
Hello, I have a multipage tiff file which I am trying to output to a web browser using Response.BinaryWrite. I am taking the tiff file, then looping for each page and saving it off to a jpg in a memory stream. The problem I'm having is when the page comes up, only the first image is shown. If I save each page off in a file I can see that each page is unique and it's not a problem with the stream, it seems to be a problem with...
11
11407
by: Random | last post by:
I have tried all the Response methods I can think of (WriteFile, BinaryWrite, OutputStream) to write the byte array of a pdf file to the response. The result looks like it's trying, it comes up as a blank PDF file (without the Adobe toolbar that normally comes up). Here is the code I am using... '...fPDF is my Byte array '...I've already verified it is valid by writing the array to a physical file ("result.pdf") and opening it...
1
2925
by: Charlie | last post by:
Hi: I'm uploading documents into a SQL Server Image field and using Response.BinaryWrite() to download or view them in the browser. Some doc types like Adobe Illustrator and Photoshop files will open correctly, but other like Word, Excel and Powerpoint are corrupt. Here is code fragment to upload: // Get file in byte array int fileLen = this.TextBoxFileToUpload.PostedFile.ContentLength;
2
2955
by: jhansl | last post by:
Hello, I am trying desperately how to find out if the bytes sent in a Response.BinaryWrite (or bytes written to Response.OutputStream) are ACTUALLY sent to the client. My problem is that I have files I would like to send to client only one time, so I need to check to see that all the bytes were actually sent to the client. As far as I can tell, there seems to be no way of checking to see if the bytes were sent. If I run a test and...
0
10216
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...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
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
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
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
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.