473,698 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with asp page returning a jpg image...

I have a problem with a page show_image.asp that returns a jpg image under
Windows XP Pro SP2. The page sets content type as:

Response.Conten tType = "image/jpg"

While this works perfectly fine on most machines, on some machines I
experience this problem:

When loading the page a window pops up that asks if I want to open the
document show_page.asp. When I click "Open" Interdev pops up and opens up a
window titled show_image.asp but the contents of that page has a few html
tags at the top followed by the binary jpg data. In fact, if I delete the
html tags and save the page as something.jpg and then look at it, it shows
the expected image.

I've noticed this problem before and found on some machines that disabling
server side debugging for the virtual directory in IIS admin does the trick.
On other occasions, I recreated the server extensions and that solved it. I
have never completely managed to understand why this happens and a reliable
way to fix it.

Any ideas?
Oct 4 '06 #1
23 5922

Peter wrote:
I have a problem with a page show_image.asp that returns a jpg image under
Windows XP Pro SP2. The page sets content type as:

Response.Conten tType = "image/jpg"

While this works perfectly fine on most machines, on some machines I
experience this problem:

When loading the page a window pops up that asks if I want to open the
document show_page.asp. When I click "Open" Interdev pops up and opens up a
window titled show_image.asp but the contents of that page has a few html
tags at the top followed by the binary jpg data.
Why not show us "show_page.asp" ??

Oct 10 '06 #2
OK, here it goes:

test.asp
--------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>Test Warehouse layout</title>
</head>
<body>
<img src="show_image .asp">
</body>
</html>
show_image.asp:
---------------
<%@ Language=VBScri pt %>
<%
Option Explicit

Response.Expire s = -1
Response.Buffer = True
Response.Conten tType = "image/jpg"

Dim objWarehouse

Set objWarehouse = mlobjAPP3Databa se.Warehouse()

If Not objWarehouse Is Nothing Then
Response.Binary Write objWarehouse.La youtJPG()
End If
%>

Please don't forget that this works on most machines. However, I frequently
have troubles on development machines and wonder if it has something to do
with server/client side debugging being enabled for IIS or if it has
something to do with frontpage or interdev IIS extensions.

Pete

"Larry Bud" <la**********@y ahoo.comwrote in message
news:11******** **************@ c28g2000cwb.goo glegroups.com.. .
>
Peter wrote:
>I have a problem with a page show_image.asp that returns a jpg image
under
Windows XP Pro SP2. The page sets content type as:

Response.Conte ntType = "image/jpg"

While this works perfectly fine on most machines, on some machines I
experience this problem:

When loading the page a window pops up that asks if I want to open the
document show_image.asp. When I click "Open" Interdev pops up and opens
up a
window titled show_image.asp but the contents of that page has a few html
tags at the top followed by the binary jpg data.

Why not show us "show_image.asp "??

Oct 12 '06 #3
Peter wrote:
Response.Conten tType = "image/jpg"
If you look at the content-type sent by the browser when you UPLOAD a jpg
file, you will find that it is "image/jpeg", not "image/jpg". Furthermore,
IIS 6 sends "image/jpeg" in the content-type header for .jpg requests. Try
changing your code to a recognized content type.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Oct 12 '06 #4
Thanks heaps Dave, your reply was spot on and fix my problem!!!

"Dave Anderson" <NY**********@s pammotel.comwro te in message
news:ez******** ******@TK2MSFTN GP03.phx.gbl...
Peter wrote:
>Response.Conte ntType = "image/jpg"

If you look at the content-type sent by the browser when you UPLOAD a jpg
file, you will find that it is "image/jpeg", not "image/jpg". Furthermore,
IIS 6 sends "image/jpeg" in the content-type header for .jpg requests. Try
changing your code to a recognized content type.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.
Use of this email address implies consent to these terms.

Oct 12 '06 #5
Now I have a similar problem again on another machine.

In the message below I used Response.Conten tType = "image/jpg" and after
changing it to Response.Conten tType = "image/jpeg" it alworked on the
machine I had trouble back then.

Now I have a similar problem once again even though I am now returning the
correct mime type.

The behaviour is as follows:

IE 7.0:
http://localhost/test.asp simply shows the icon for a missing image instead
of the image
http://localhost/show_image.asp shows some raw image data

Mozilla Firefox 2.0:
http://localhost/test.asp simply shows the icon for a missing image instead
of the image
http://localhost/show_image.asp shows the URL as text in the client area
instead of the image

I ammendet show_image.asp to also write the binary data to an physical file
c:\temp\image.j pg. I can see that the image is updated each time i request
either of the two URL's and this works fine. Furthermore, the image looks
fine too.

I really have no idea what is wrong with... Is this an incorrect approach???

Pete
"Peter" <peteATkapiti.c o.nzwrote in message
news:O9******** ******@TK2MSFTN GP03.phx.gbl...
OK, here it goes:

test.asp
--------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>Test Warehouse layout</title>
</head>
<body>
<img src="show_image .asp">
</body>
</html>
show_image.asp:
---------------
<%@ Language=VBScri pt %>
<%
Option Explicit

Response.Expire s = -1
Response.Buffer = True
Response.Conten tType = "image/jpg"

Dim objWarehouse

Set objWarehouse = mlobjAPP3Databa se.Warehouse()

If Not objWarehouse Is Nothing Then
Response.Binary Write objWarehouse.La youtJPG()
End If
%>

Please don't forget that this works on most machines. However, I
frequently have troubles on development machines and wonder if it has
something to do with server/client side debugging being enabled for IIS or
if it has something to do with frontpage or interdev IIS extensions.

Pete

"Larry Bud" <la**********@y ahoo.comwrote in message
news:11******** **************@ c28g2000cwb.goo glegroups.com.. .
>>
Peter wrote:
>>I have a problem with a page show_image.asp that returns a jpg image
under
Windows XP Pro SP2. The page sets content type as:

Response.Cont entType = "image/jpg"

While this works perfectly fine on most machines, on some machines I
experience this problem:

When loading the page a window pops up that asks if I want to open the
document show_image.asp. When I click "Open" Interdev pops up and opens
up a
window titled show_image.asp but the contents of that page has a few
html
tags at the top followed by the binary jpg data.

Why not show us "show_image.asp "??


Nov 16 '06 #6
Peter wrote:
Now I have a similar problem again on another machine.

In the message below I used Response.Conten tType = "image/jpg" and
after changing it to Response.Conten tType = "image/jpeg" it alworked
on the machine I had trouble back then.

Now I have a similar problem once again even though I am now
returning the correct mime type.

The behaviour is as follows:

IE 7.0:
http://localhost/test.asp simply shows the icon for a missing image
instead of the image
http://localhost/show_image.asp shows some raw image data

Mozilla Firefox 2.0:
http://localhost/test.asp simply shows the icon for a missing image
instead of the image
http://localhost/show_image.asp shows the URL as text in the client
area instead of the image
I see several conditions here that are not accounted for:
>>Set objWarehouse = mlobjAPP3Databa se.Warehouse()
If Not objWarehouse Is Nothing Then
Response.Binary Write objWarehouse.La youtJPG()
End If
Since we know almost nothing about mlobjAPP3Databa se, it isn't clear that
the choices are [Nothing] and [an object with nontrivial method
LayoutJPG()]. Moreover, the method name suggests the image is always in the
jpeg format. Are you certain this is the case?
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Nov 17 '06 #7
"Dave Anderson" <NY**********@s pammotel.comwro te in message
news:ug******** *****@TK2MSFTNG P02.phx.gbl...
Peter wrote:
>Now I have a similar problem again on another machine.

In the message below I used Response.Conten tType = "image/jpg" and
after changing it to Response.Conten tType = "image/jpeg" it alworked
on the machine I had trouble back then.

Now I have a similar problem once again even though I am now
returning the correct mime type.

The behaviour is as follows:

IE 7.0:
http://localhost/test.asp simply shows the icon for a missing image
instead of the image
http://localhost/show_image.asp shows some raw image data

Mozilla Firefox 2.0:
http://localhost/test.asp simply shows the icon for a missing image
instead of the image
http://localhost/show_image.asp shows the URL as text in the client
area instead of the image

I see several conditions here that are not accounted for:
>>>Set objWarehouse = mlobjAPP3Databa se.Warehouse()
If Not objWarehouse Is Nothing Then
Response.Binary Write objWarehouse.La youtJPG()
End If

Since we know almost nothing about mlobjAPP3Databa se, it isn't clear that
the choices are [Nothing] and [an object with nontrivial method
LayoutJPG()]. Moreover, the method name suggests the image is always in
the jpeg format. Are you certain this is the case?
I accept your concerns, but I have reduced to code to the protions which are
relevant for this dicussion. The problem is not with my code, the problem is
somewhere with the configuration of IIS.

I have expanded show_image.asp with the following function:

Function SaveBinaryData( FileName, ByteArray)
Const adTypeBinary = 1
Const adSaveCreateOve rWrite = 2

'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("A DODB.Stream")

'Specify stream type - we want To save binary data.
BinaryStream.Ty pe = adTypeBinary

'Open the stream And write binary data To the object
BinaryStream.Op en
BinaryStream.Wr ite ByteArray

'Save binary data To disk
BinaryStream.Sa veToFile FileName, adSaveCreateOve rWrite
End Function

Now not only do I write the raw data back to the client, I also write it to
a physical file:

Response.Binary Write objWarehouse.La youtJPG()
SaveBinaryData "c:\temp\mypic. jpg", objWarehouse.La youtJPG()

Not only can I see that c:\temp\mypic.j pg get's written correctly everytime
I request the page from the web server, my web browsers and image viewers
show the expected image when I open the file explicitly.

There must be something wrong with IIS, I suspect it has something to do
with front page server extensions or extensions needed for MS InterDev.

Pete
Nov 19 '06 #8

"Peter" <peteATkapiti.c o.nzwrote in message
news:e3******** ******@TK2MSFTN GP02.phx.gbl...
"Dave Anderson" <NY**********@s pammotel.comwro te in message
news:ug******** *****@TK2MSFTNG P02.phx.gbl...
>Peter wrote:
>>Now I have a similar problem again on another machine.

In the message below I used Response.Conten tType = "image/jpg" and
after changing it to Response.Conten tType = "image/jpeg" it alworked
on the machine I had trouble back then.

Now I have a similar problem once again even though I am now
returning the correct mime type.

The behaviour is as follows:

IE 7.0:
http://localhost/test.asp simply shows the icon for a missing image
instead of the image
http://localhost/show_image.asp shows some raw image data

Mozilla Firefox 2.0:
http://localhost/test.asp simply shows the icon for a missing image
instead of the image
http://localhost/show_image.asp shows the URL as text in the client
area instead of the image

I see several conditions here that are not accounted for:
>>>>Set objWarehouse = mlobjAPP3Databa se.Warehouse()
If Not objWarehouse Is Nothing Then
Response.Binary Write objWarehouse.La youtJPG()
End If

Since we know almost nothing about mlobjAPP3Databa se, it isn't clear that
the choices are [Nothing] and [an object with nontrivial method
LayoutJPG()]. Moreover, the method name suggests the image is always in
the jpeg format. Are you certain this is the case?

I accept your concerns, but I have reduced to code to the protions which
are relevant for this dicussion. The problem is not with my code, the
problem is somewhere with the configuration of IIS.

I have expanded show_image.asp with the following function:

Function SaveBinaryData( FileName, ByteArray)
Const adTypeBinary = 1
Const adSaveCreateOve rWrite = 2

'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("A DODB.Stream")

'Specify stream type - we want To save binary data.
BinaryStream.Ty pe = adTypeBinary

'Open the stream And write binary data To the object
BinaryStream.Op en
BinaryStream.Wr ite ByteArray

'Save binary data To disk
BinaryStream.Sa veToFile FileName, adSaveCreateOve rWrite
End Function

Now not only do I write the raw data back to the client, I also write it
to a physical file:

Response.Binary Write objWarehouse.La youtJPG()
SaveBinaryData "c:\temp\mypic. jpg", objWarehouse.La youtJPG()

Not only can I see that c:\temp\mypic.j pg get's written correctly
everytime I request the page from the web server, my web browsers and
image viewers show the expected image when I open the file explicitly.

There must be something wrong with IIS, I suspect it has something to do
with front page server extensions or extensions needed for MS InterDev.
Surprise, surprise...

I now find that if I change show_image.asp as follows all works fine (note
that all I changed was inserting a Response.Clear before and Response.Flush
after writing the binary data to the output stream). Why would that be?

<%@ Language=VBScri pt %>
<%
Option Explicit

Response.Expire s = -1
Response.Buffer = True

Dim objWarehouse

Set objWarehouse = mlobjAPP3Databa se.Warehouse()

If Not objWarehouse Is Nothing Then
Response.Clear
Response.Conten tType = "image/jpeg"
Response.Binary Write objWarehouse.La youtJPG()
Response.Flush
End If
%>
Nov 19 '06 #9

"Peter" <peteATkapiti.c o.nzwrote in message
news:u0******** ******@TK2MSFTN GP04.phx.gbl...
>
"Peter" <peteATkapiti.c o.nzwrote in message
news:e3******** ******@TK2MSFTN GP02.phx.gbl...
"Dave Anderson" <NY**********@s pammotel.comwro te in message
news:ug******** *****@TK2MSFTNG P02.phx.gbl...
Peter wrote:
Now I have a similar problem again on another machine.

In the message below I used Response.Conten tType = "image/jpg" and
after changing it to Response.Conten tType = "image/jpeg" it alworked
on the machine I had trouble back then.

Now I have a similar problem once again even though I am now
returning the correct mime type.

The behaviour is as follows:

IE 7.0:
http://localhost/test.asp simply shows the icon for a missing image
instead of the image
http://localhost/show_image.asp shows some raw image data

Mozilla Firefox 2.0:
http://localhost/test.asp simply shows the icon for a missing image
instead of the image
http://localhost/show_image.asp shows the URL as text in the client
area instead of the image

I see several conditions here that are not accounted for:

Set objWarehouse = mlobjAPP3Databa se.Warehouse()
If Not objWarehouse Is Nothing Then
Response.Binary Write objWarehouse.La youtJPG()
End If

Since we know almost nothing about mlobjAPP3Databa se, it isn't clear
that
the choices are [Nothing] and [an object with nontrivial method
LayoutJPG()]. Moreover, the method name suggests the image is always in
the jpeg format. Are you certain this is the case?
I accept your concerns, but I have reduced to code to the protions which
are relevant for this dicussion. The problem is not with my code, the
problem is somewhere with the configuration of IIS.

I have expanded show_image.asp with the following function:

Function SaveBinaryData( FileName, ByteArray)
Const adTypeBinary = 1
Const adSaveCreateOve rWrite = 2

'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("A DODB.Stream")

'Specify stream type - we want To save binary data.
BinaryStream.Ty pe = adTypeBinary

'Open the stream And write binary data To the object
BinaryStream.Op en
BinaryStream.Wr ite ByteArray

'Save binary data To disk
BinaryStream.Sa veToFile FileName, adSaveCreateOve rWrite
End Function

Now not only do I write the raw data back to the client, I also write it
to a physical file:

Response.Binary Write objWarehouse.La youtJPG()
SaveBinaryData "c:\temp\mypic. jpg", objWarehouse.La youtJPG()

Not only can I see that c:\temp\mypic.j pg get's written correctly
everytime I request the page from the web server, my web browsers and
image viewers show the expected image when I open the file explicitly.

There must be something wrong with IIS, I suspect it has something to do
with front page server extensions or extensions needed for MS InterDev.

Surprise, surprise...

I now find that if I change show_image.asp as follows all works fine (note
that all I changed was inserting a Response.Clear before and
Response.Flush
after writing the binary data to the output stream). Why would that be?

<%@ Language=VBScri pt %>
<%
Option Explicit

Response.Expire s = -1
Response.Buffer = True

Dim objWarehouse

Set objWarehouse = mlobjAPP3Databa se.Warehouse()

If Not objWarehouse Is Nothing Then
Response.Clear
Response.Conten tType = "image/jpeg"
Response.Binary Write objWarehouse.La youtJPG()
Response.Flush
End If
%>
Sounds like there is some code running before this that was generating some
output in the buffer.
does the page have an include file that might be doing this?
Is the page arrived at via Server.Transfer or Server.Execute?

If you remove the .Flush does the problem come back?
Nov 20 '06 #10

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

Similar topics

5
4233
by: Phil Powell | last post by:
I created a page that will be doing image resizing and manipulation, which seems to work (using GD library). However, upon returning to the page where the image has been changed, I still see the old image, until I refresh my browser and then zappo, there it is! All changed! I have done everything I can think of to force caching including this: // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
0
1848
by: Lee | last post by:
I am having a problem returning an image that I got from SQL Server from within an ASP page that got requested from a VC++ application. Specifically, within my application, I make an HTTP call to my IIS server to an ASP. The ASP then queries a SQL Server and the field that I want to return from the resulting Recordset is an image. In the application, I then make a call to receive the response from the web page but am having no luck...
0
1820
by: Gunther Schmidl | last post by:
Hi, I've rolled my own perl component for resizing pictures on the fly, but I have a problem with actually outputting the resized image. Here's my code: Dim res Response.Buffer = true Set res = Server.CreateObject("ResCom.Resizer")
7
2082
by: Sunny | last post by:
Hi all, I have found a possible bug in the Uri class constructor. When I make something like this: test = new Uri(@"http://www.test.com/dir1/page1.html"); test2 = new Uri(test, @"../../page2.html"); in test2.AbsolutetPath I receive http://www.test.com/../page2.html. I know that you can not go before the /test/ dir, and that why there is
6
5584
by: David Bowey | last post by:
Hi There! I'm writing a custom HttpHandler to create watermarks on my PNG images of my website. So typically, a PNG image is linked in an ASPX page as follows... <img src="images/test.png" alt="testing" /> So I created an HttpHanlder to handle PNG images, have mapped the PNG extension in the IIS and also added the HttpModule section in the web.config file.
2
3180
by: tparks69 | last post by:
All I need to do is set the border property of an image control to border=0. I want to do this at runtime for the first image on the page in a datalist. In the ItemCreated event I'm trying to use FindControl to set a reference to the img control so I can change the attribute. But when I run the code below I get the error: "Object reference not set to an instance of an object." I assume its not finding the control and returning null? ...
1
1976
by: kiergaro | last post by:
I understand there is no way for the Server to see the Client printers, but I have a routine that generates a bunch of bar codes on a page and keeps it stored in a Graphics variable. Is there any way possible to take the graphics variable and put it in a printable window using windows.print() in Javascript? Basically i'm doing something like this in the PrintPage() Dim grfx As Graphics
10
10712
by: =?Utf-8?B?UmludSBHb3BhbGFrcmlzaG5hIFBpbGxhaQ==?= | last post by:
Hi, Please help me to write a dll in C# , that will read each pages of a tiff image from a file and a memory stream object ( need two ways) and creatre a new tiff image object.The dll should return the combined tif image object. Thnks in advance Rinu G P
16
3743
by: Jm.GlezdeRueda | last post by:
Hi all, Im trying to read a 24bit bmp with fread, and i have some problems.. I want to read the whole structure in one time, but i dont know why, it only reads the first member well.. I have two questions.. 1- why if i change fread(bmp1, sizeof(bmp1), 1, fin); to fread(bmp1, sizeof(struct bmp), 1, fin); i have a Segment violation ??
0
8673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8601
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9021
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
8860
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...
1
6518
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
5860
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
4365
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...
1
3043
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
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.