Streaming an Image with C#/Firefox

Log in to stop seeing adverts
This page may contain links to companies such as eBay and Amazon. As an affiliate of these sites I may earn commission if you click the link and make a purchase

Status
Not open for further replies.

Matt_B

Well-Known Member
Roit, let's try this on for size.

I have a dynamic image resizing class in my project, that will take the uploaded image and create and save thumbnail versions.

When required these are then loaded using a FileStream method (below) and streamed to a page.

I can access the image using an <img src='path to script' /> and it works fine, the problem is, if in Firefox I right click and select View Image I get the attached screen shot. If I type the same URL into IE7 or IE6 it works fine and displays the thumbnail.

I assume this is something to do with the mimetype or encoding, but as far as I am aware they are correct, any idea?

screenshot
image error.jpg

code block

Code:
FileStream oStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
                long FileSize;
                FileSize = oStream.Length;
                byte[] getContent = new byte[(int)FileSize];
                oStream.Read(getContent, 0, (int)oStream.Length);
                oStream.Close();

HttpContext.Response.Clear();
                HttpContext.Response.Buffer = true;

                HttpContext.Response.ContentType = "image/jpeg";

                HttpContext.Response.BinaryWrite(getContent);

This is now driving me mad for such a small issue.
 
Edit: Fecking w*nk tw*t, noob error. I forgot the Response.End() at the end, it was interpreting a single white space in the page as HTML content (correctly I suppose) and so not rendering the image. Close the thread.
 
Status
Not open for further replies.
Log in to stop seeing adverts

P Pld Pts
1Liverpool1639
2Chelsea1735
3Arsenal1733
4Nottm F1731
5Bournemouth1728
6Aston Villa1728
7Manchester C  1727
8Newcastle1726
9Fulham1725
10Brighton1725
11Tottenham 1723
12Brentford1723
13Manchester U1722
14West Ham1720
15Everton1616
16Palace1716
17Leicester1714
18Wolves1712
19Ipswich1712
20Southampton176

Latest posts

Back
Top