473,326 Members | 2,012 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,326 software developers and data experts.

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.ContentType = "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 5807

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.ContentType = "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=VBScript %>
<%
Option Explicit

Response.Expires = -1
Response.Buffer = True
Response.ContentType = "image/jpg"

Dim objWarehouse

Set objWarehouse = mlobjAPP3Database.Warehouse()

If Not objWarehouse Is Nothing Then
Response.BinaryWrite objWarehouse.LayoutJPG()
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**********@yahoo.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.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.ContentType = "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.ContentType = "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**********@spammotel.comwrote in message
news:ez**************@TK2MSFTNGP03.phx.gbl...
Peter wrote:
>Response.ContentType = "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.ContentType = "image/jpg" and after
changing it to Response.ContentType = "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.jpg. 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.co.nzwrote in message
news:O9**************@TK2MSFTNGP03.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=VBScript %>
<%
Option Explicit

Response.Expires = -1
Response.Buffer = True
Response.ContentType = "image/jpg"

Dim objWarehouse

Set objWarehouse = mlobjAPP3Database.Warehouse()

If Not objWarehouse Is Nothing Then
Response.BinaryWrite objWarehouse.LayoutJPG()
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**********@yahoo.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.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.ContentType = "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.ContentType = "image/jpg" and
after changing it to Response.ContentType = "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 = mlobjAPP3Database.Warehouse()
If Not objWarehouse Is Nothing Then
Response.BinaryWrite objWarehouse.LayoutJPG()
End If
Since we know almost nothing about mlobjAPP3Database, 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**********@spammotel.comwrote in message
news:ug*************@TK2MSFTNGP02.phx.gbl...
Peter wrote:
>Now I have a similar problem again on another machine.

In the message below I used Response.ContentType = "image/jpg" and
after changing it to Response.ContentType = "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 = mlobjAPP3Database.Warehouse()
If Not objWarehouse Is Nothing Then
Response.BinaryWrite objWarehouse.LayoutJPG()
End If

Since we know almost nothing about mlobjAPP3Database, 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 adSaveCreateOverWrite = 2

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

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

'Open the stream And write binary data To the object
BinaryStream.Open
BinaryStream.Write ByteArray

'Save binary data To disk
BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Function

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

Response.BinaryWrite objWarehouse.LayoutJPG()
SaveBinaryData "c:\temp\mypic.jpg", objWarehouse.LayoutJPG()

Not only can I see that c:\temp\mypic.jpg 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.co.nzwrote in message
news:e3**************@TK2MSFTNGP02.phx.gbl...
"Dave Anderson" <NY**********@spammotel.comwrote in message
news:ug*************@TK2MSFTNGP02.phx.gbl...
>Peter wrote:
>>Now I have a similar problem again on another machine.

In the message below I used Response.ContentType = "image/jpg" and
after changing it to Response.ContentType = "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 = mlobjAPP3Database.Warehouse()
If Not objWarehouse Is Nothing Then
Response.BinaryWrite objWarehouse.LayoutJPG()
End If

Since we know almost nothing about mlobjAPP3Database, 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 adSaveCreateOverWrite = 2

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

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

'Open the stream And write binary data To the object
BinaryStream.Open
BinaryStream.Write ByteArray

'Save binary data To disk
BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Function

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

Response.BinaryWrite objWarehouse.LayoutJPG()
SaveBinaryData "c:\temp\mypic.jpg", objWarehouse.LayoutJPG()

Not only can I see that c:\temp\mypic.jpg 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=VBScript %>
<%
Option Explicit

Response.Expires = -1
Response.Buffer = True

Dim objWarehouse

Set objWarehouse = mlobjAPP3Database.Warehouse()

If Not objWarehouse Is Nothing Then
Response.Clear
Response.ContentType = "image/jpeg"
Response.BinaryWrite objWarehouse.LayoutJPG()
Response.Flush
End If
%>
Nov 19 '06 #9

"Peter" <peteATkapiti.co.nzwrote in message
news:u0**************@TK2MSFTNGP04.phx.gbl...
>
"Peter" <peteATkapiti.co.nzwrote in message
news:e3**************@TK2MSFTNGP02.phx.gbl...
"Dave Anderson" <NY**********@spammotel.comwrote in message
news:ug*************@TK2MSFTNGP02.phx.gbl...
Peter wrote:
Now I have a similar problem again on another machine.

In the message below I used Response.ContentType = "image/jpg" and
after changing it to Response.ContentType = "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 = mlobjAPP3Database.Warehouse()
If Not objWarehouse Is Nothing Then
Response.BinaryWrite objWarehouse.LayoutJPG()
End If

Since we know almost nothing about mlobjAPP3Database, 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 adSaveCreateOverWrite = 2

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

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

'Open the stream And write binary data To the object
BinaryStream.Open
BinaryStream.Write ByteArray

'Save binary data To disk
BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Function

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

Response.BinaryWrite objWarehouse.LayoutJPG()
SaveBinaryData "c:\temp\mypic.jpg", objWarehouse.LayoutJPG()

Not only can I see that c:\temp\mypic.jpg 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=VBScript %>
<%
Option Explicit

Response.Expires = -1
Response.Buffer = True

Dim objWarehouse

Set objWarehouse = mlobjAPP3Database.Warehouse()

If Not objWarehouse Is Nothing Then
Response.Clear
Response.ContentType = "image/jpeg"
Response.BinaryWrite objWarehouse.LayoutJPG()
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
Anthony Jones wrote:
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?
This was my first question, but the example he provided had no other output.
Once he explained that he had stripped out the chaff, it became clear there
was probably more content in the Response buffer.

This, by the way, is why I complete all processing before letting a script
produce output. I do not even allow context switching until all connections
are closed and decisions are made[1].


[1] There is no point in putting something in the buffer if I'm going to use
Response.Redirect, for example. A small amount of looping and conditional
display is acceptible in the template, of course.

--
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 20 '06 #11

"Anthony Jones" <An*@yadayadayada.comwrote in message
news:OE**************@TK2MSFTNGP02.phx.gbl...
>
"Peter" <peteATkapiti.co.nzwrote in message
news:u0**************@TK2MSFTNGP04.phx.gbl...
>>
"Peter" <peteATkapiti.co.nzwrote in message
news:e3**************@TK2MSFTNGP02.phx.gbl...
"Dave Anderson" <NY**********@spammotel.comwrote in message
news:ug*************@TK2MSFTNGP02.phx.gbl...
Peter wrote:
Now I have a similar problem again on another machine.

In the message below I used Response.ContentType = "image/jpg" and
after changing it to Response.ContentType = "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 = mlobjAPP3Database.Warehouse()
If Not objWarehouse Is Nothing Then
Response.BinaryWrite objWarehouse.LayoutJPG()
End If

Since we know almost nothing about mlobjAPP3Database, 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 adSaveCreateOverWrite = 2

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

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

'Open the stream And write binary data To the object
BinaryStream.Open
BinaryStream.Write ByteArray

'Save binary data To disk
BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Function

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

Response.BinaryWrite objWarehouse.LayoutJPG()
SaveBinaryData "c:\temp\mypic.jpg", objWarehouse.LayoutJPG()

Not only can I see that c:\temp\mypic.jpg 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=VBScript %>
<%
Option Explicit

Response.Expires = -1
Response.Buffer = True

Dim objWarehouse

Set objWarehouse = mlobjAPP3Database.Warehouse()

If Not objWarehouse Is Nothing Then
Response.Clear
Response.ContentType = "image/jpeg"
Response.BinaryWrite objWarehouse.LayoutJPG()
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?
This is plain old ASP (btw I'm a C++ programmer not ASP programmer and I
wrote the component producing the image), so I don't know what
Server.Execute or Server.Transfer is. The page is referenced by using the
image tag in a calling page:

<img src="show_image.asp">

but you could equally well load the page directly.

It is true that I do include another asp file in the real McCoy but the only
time the include writes to the Response stream is to write an error message
which is immediately followed by a Response.End call.

I can remove the Flush and it still works perfectly fine, but if I remove
the Clear it fails on that particular machine but works perfectly fine on
many others.

I hate the whole approach because it has a few flaws even if it works.
Another thing I omitted is that show_image.asp actually takes some
parameters (query string) like objectID, imgwidth, imgheight and rotation.
Not all objects have images so I tried IFRAME instead of IMG and this works
already a lot better since the page I'm loading can return any of the
recognised content types and the browser can render it correctly. In other
words, since I can return a jpg image, plain text, html, etc. I can return
an error message if something goes wrong or the image if all works fine. But
this approach too has it's flaws and feels like killing a fly with a cannon.

Isn't there a better way to accomplish this?
Nov 20 '06 #12

"Peter" <peteATkapiti.co.nzwrote in message
news:u0**************@TK2MSFTNGP04.phx.gbl...
>
If you remove the .Flush does the problem come back?

This is plain old ASP (btw I'm a C++ programmer not ASP programmer and I
wrote the component producing the image), so I don't know what
Server.Execute or Server.Transfer is. The page is referenced by using the
image tag in a calling page:
As a C++ programmer have you considered using an ISAPI filter or extension
to acheive your goal.
>
<img src="show_image.asp">

but you could equally well load the page directly.
Yes but instead of a html page you would be loading an image which browsers
are quite happy to do.
>
It is true that I do include another asp file in the real McCoy but the
only
time the include writes to the Response stream is to write an error
message
which is immediately followed by a Response.End call.
Does it have any html mark up outside to the <%%script delimiters. At the
end of the day _something_ is adding this extra html markup into your output
buffer. Does the application/parent application/site/server have any
unusual ISAPI filters loaded?
>
I can remove the Flush and it still works perfectly fine
Then leave it out. There are very few genuine uses for Flush if any.
but if I remove
the Clear it fails on that particular machine but works perfectly fine on
many others.
That's real strange. It would suggest that some machines are perfectly
happy to swallow the preceeding html markup and ignore it.

Does your ASP page set Expires or CacheControl properties of the Response
object?
Is it possible that the failing machine is actually retrieving an earlier
corrupt resource from it's cache?
>
I hate the whole approach because it has a few flaws even if it works.
Such as?
Another thing I omitted is that show_image.asp actually takes some
parameters (query string) like objectID, imgwidth, imgheight and rotation.
Not a problem
Not all objects have images so I tried IFRAME instead of IMG and this
works
already a lot better since the page I'm loading can return any of the
recognised content types and the browser can render it correctly. In other
words, since I can return a jpg image, plain text, html, etc. I can return
an error message if something goes wrong or the image if all works fine.
But
this approach too has it's flaws and feels like killing a fly with a
cannon.
>
Isn't there a better way to accomplish this?
If you're up for it then an ISAPI extension is a better solution. However
the complexity may outweigh the benefits.

Would it be true to say that ven the exact same set of query string values
the page would return the exact same image. If so then consider using

Response.Expires = <large number of minutes>
Response.CacheControl = "max-age=" & <large number of minutes* 60
Response.AddHeader "ETag", "imageasp" & <some uniqueID for this exact image>

This will cause the client to cache this image. Subsequent rquests for this
image will be fulfilled from the cache.

Nov 21 '06 #13
Anthony Jones wrote:
Does it have any html mark up outside to the <%%script
delimiters.
More to the point, is there anything AT ALL (even whitespace) outside the
script delimiters?


--
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 21 '06 #14
"Anthony Jones" <An*@yadayadayada.comwrote in message
news:On*************@TK2MSFTNGP03.phx.gbl...
>
"Peter" <peteATkapiti.co.nzwrote in message
news:u0**************@TK2MSFTNGP04.phx.gbl...
>>
If you remove the .Flush does the problem come back?

This is plain old ASP (btw I'm a C++ programmer not ASP programmer and I
wrote the component producing the image), so I don't know what
Server.Execute or Server.Transfer is. The page is referenced by using the
image tag in a calling page:

As a C++ programmer have you considered using an ISAPI filter or extension
to acheive your goal.
A long time ago we did but at the time we decided against it because we felt
that implementing a robust COM interface was a challenge enough.
>It is true that I do include another asp file in the real McCoy but the
only
>time the include writes to the Response stream is to write an error
message
>which is immediately followed by a Response.End call.

Does it have any html mark up outside to the <%%script delimiters. At
the
end of the day _something_ is adding this extra html markup into your
output
buffer. Does the application/parent application/site/server have any
unusual ISAPI filters loaded?
I may have something like that:

' script finishes before this line
%>

<!--#Include File="_lib/pagestart.asp"-->

<%
' more scripts follow

Now would this write whitespace to the response stream?
Does your ASP page set Expires or CacheControl properties of the Response
object?
This is all I do currently:

Response.Expires = -1
Response.Buffer = True

Is it possible that the failing machine is actually retrieving an earlier
corrupt resource from it's cache?
I was hoping setting Response.Expires = -1 would cause a reload each
time!?!?
>I hate the whole approach because it has a few flaws even if it works.

Such as?
What I hate is that my asp page that returns the image can't always return
an image. Sometimes I can return text/plain or text/html instead of
image/jpeg. But when I use the page as src attribute in an img tag it must
return an image/* document so I can't easily return error messages.
If you're up for it then an ISAPI extension is a better solution. However
the complexity may outweigh the benefits.
I think there is no justification at present since I know have it working
better as is. Also, at present I don't have any machine that fails
displaying graphics.
Would it be true to say that ven the exact same set of query string values
the page would return the exact same image. If so then consider using
Unfortunately no. The COM server is rather a complex beast and has loads of
runtime configurable parameters. Many of those can impact the 2D diagrams it
produces.

I really appreciate your feedback on this BTW! Many thanks Anthony and Dave!

Nov 22 '06 #15
Peter wrote:
I may have something like that:

' script finishes before this line
%>

<!--#Include File="_lib/pagestart.asp"-->

<%
' more scripts follow

Now would this write whitespace to the response stream?
Yes, not to mention the possible contents of the include file.

--
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 22 '06 #16

"Peter" <peteATkapiti.co.nzwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"Anthony Jones" <An*@yadayadayada.comwrote in message
news:On*************@TK2MSFTNGP03.phx.gbl...

"Peter" <peteATkapiti.co.nzwrote in message
news:u0**************@TK2MSFTNGP04.phx.gbl...
>
If you remove the .Flush does the problem come back?

This is plain old ASP (btw I'm a C++ programmer not ASP programmer and
I
wrote the component producing the image), so I don't know what
Server.Execute or Server.Transfer is. The page is referenced by using
the
image tag in a calling page:
As a C++ programmer have you considered using an ISAPI filter or
extension
to acheive your goal.

A long time ago we did but at the time we decided against it because we
felt
that implementing a robust COM interface was a challenge enough.
I hear ya! ;) One approach I've used is to create the a standard dll with
C++ using StdCall exported functions. Create a typelib for those functions.
Then build a VB6 ActiveX dll project that references the typelib and exposes
a Script compatible set of COM objects. That way you let VB6 handle
creating COM interfaces and stick to what you know in C++ (which in my case
isn't a great deal).
It is true that I do include another asp file in the real McCoy but the
only
time the include writes to the Response stream is to write an error
message
which is immediately followed by a Response.End call.
Does it have any html mark up outside to the <%%script delimiters. At
the
end of the day _something_ is adding this extra html markup into your
output
buffer. Does the application/parent application/site/server have any
unusual ISAPI filters loaded?

I may have something like that:

' script finishes before this line
%>

<!--#Include File="_lib/pagestart.asp"-->

<%
' more scripts follow

Now would this write whitespace to the response stream?
Like Dave said, this is very likely the culprit, it will at least be placing
a couple or three CR LFs in the output.
>
Does your ASP page set Expires or CacheControl properties of the
Response
object?

This is all I do currently:

Response.Expires = -1
Response.Buffer = True

Is it possible that the failing machine is actually retrieving an
earlier
corrupt resource from it's cache?

I was hoping setting Response.Expires = -1 would cause a reload each
time!?!?
Yes should be. Although it does require that the client clock be in
reasonable sync with the server clock. E.g. if the clients clock is 5
minutes slow then Response.Expires=-1 allows the resource to remain fresh
for 4 minutes.

I tend to use Response.Expires = 0 and trust the clocks are reasonably in
sync. However I also use:
Response.CacheControl = "max-age=0" which is the HTTP/1.1 method of
specifying freshness in seconds.

I hate the whole approach because it has a few flaws even if it works.
Such as?

What I hate is that my asp page that returns the image can't always return
an image. Sometimes I can return text/plain or text/html instead of
image/jpeg. But when I use the page as src attribute in an img tag it must
return an image/* document so I can't easily return error messages.
In that case you might consider inventing an 'Error.gif' which you can send
in place of the image when an error occurs.
If you're up for it then an ISAPI extension is a better solution.
However
the complexity may outweigh the benefits.

I think there is no justification at present since I know have it working
better as is. Also, at present I don't have any machine that fails
displaying graphics.
Would it be true to say that ven the exact same set of query string
values
the page would return the exact same image. If so then consider using

Unfortunately no. The COM server is rather a complex beast and has loads
of
runtime configurable parameters. Many of those can impact the 2D diagrams
it
produces.
In that case it does sound like you will need to ensure the resource is
checked every time.
I really appreciate your feedback on this BTW! Many thanks Anthony and
Dave!
>


Nov 22 '06 #17
To summarise what I will do as a result of this thread:

1) The first statement I try to call will be Response.Buffer = True to
ensure that nothing is sent to the client

2) To ensure readability of code (blank lines in the right place assist me
when I read code I wrote yonx ago) I will continue to use the Response.Clear
command before outputing the image via Response.BinaryWrite

3) In order to retain the ability to return informative text messages when
no image is available or errors when creating the image fails for whatever
reason, I'll embed the image in an iframe tag instead of an img tag.

Thanks for all your help and suggestions Dave and Anthony! I think I have
enough clues now to tidy this all up. I guess what was really confusing (and
still is) was the fact that the same code worked on some machines but not on
others. But then again, I don't understand much about the inner workings of
different releases/configurations of IIS and now that I have a fix I don't
really care to find out.

I wish I had had guys like you on my team ;).

Pete
Nov 22 '06 #18
Peter wrote:
1) The first statement I try to call will be Response.Buffer
= True to ensure that nothing is sent to the client
Just for reference, this has been the default since IIS 5. Furthermore,
Response.Clear() throws an error if this is not already (true).
2) To ensure readability of code (blank lines in the right
place assist me when I read code I wrote yonx ago) I will
continue to use the Response.Clear command before outputing
the image via Response.BinaryWrite
Whitespace in code is a very useful tool, I agree. But the issue here was
not the presence, but the *location* of that whitespace. Supposing for a
moment that your include file contains nothing outside the ASP context
delimiters (<% on the first line, and %to end the file), then you can
retain your whitespace with a simple adjustment. Instead of this...

Some statement
%>

<!-- #include file="abcdefg.inc.asp" -->

<%
Some other statement
....you simply change it to this:
Some statement
%><!-- #include file="abcdefg.inc.asp" --><%
Some other statement
That's no less readable, right?
3) In order to retain the ability to return informative text
messages when no image is available or errors when creating
the image fails for whatever reason, I'll embed the image in
an iframe tag instead of an img tag.
This turns out to be a clever solution, so long as the browser considers
itself the proper program to handle the text/jpeg content-type. I certainly
can envision a problem similar to your original (image/jpg instead of
image/jpeg), depending on machine configuration, however.

--
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 23 '06 #19
Instead of this...

Some statement
%>

<!-- #include file="abcdefg.inc.asp" -->

<%
Some other statement
...you simply change it to this:
Some statement
%><!-- #include file="abcdefg.inc.asp" --><%
Some other statement
That's no less readable, right?
Or

%>
<!-- #include file="abcdefg.inc.asp" -->
<%

;)
Nov 23 '06 #20
Anthony Jones wrote:
Or

%>
<!-- #include file="abcdefg.inc.asp" -->
<%
No.

You should pay attention to the thread before posting something like this.
You just injected whitespace into the Response buffer, which now requires
the use of Response.Clear() before using Response.BinaryWrite().

--
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 24 '06 #21

"Dave Anderson" <NY**********@spammotel.comwrote in message
news:eI****************@TK2MSFTNGP03.phx.gbl...
Anthony Jones wrote:
Or

%>
<!-- #include file="abcdefg.inc.asp" -->
<%

No.

You should pay attention to the thread before posting something like this.
You just injected whitespace into the Response buffer, which now requires
the use of Response.Clear() before using Response.BinaryWrite().
I had a feeling you were going to say that. ;)

Perhaps you should test your assumptions before handing out reproof.

See my answer in this group to John Byrne subject 'IE7 XMLHTTPREQUEST
reponseXML' orignal post sent 23-Nov-2006 14:05 GMT
>

--
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 24 '06 #22
Anthony Jones wrote:
Perhaps you should test your assumptions before handing out reproof.

See my answer in this group to John Byrne subject 'IE7
XMLHTTPREQUEST reponseXML' orignal post sent 23-Nov-2006 14:05 GMT
XML has nothing whatsoever to do with Response.BinaryWrite(). Unexpected
whitespace characters are almost always going to corrupt the expected format
of binary data.

--
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 24 '06 #23

"Dave Anderson" <NY**********@spammotel.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Anthony Jones wrote:
Perhaps you should test your assumptions before handing out reproof.

See my answer in this group to John Byrne subject 'IE7
XMLHTTPREQUEST reponseXML' orignal post sent 23-Nov-2006 14:05 GMT

XML has nothing whatsoever to do with Response.BinaryWrite(). Unexpected
whitespace characters are almost always going to corrupt the expected
format
of binary data.
(sigh!) Clear it is you that has trouble reading. I'll cut'n'paste the
relevent portions:-
<quote>

ASP has an unfortunate behaviour in this regard:-

<!-- #include virtual="/someinclude.asp" -->
<html>
<body>
...

The CRLF before the <htmltag is included in the response of the inline
content hence extra whitespace at the start.

However something like this:-

<!-- #include virtual="/someinclude.asp" -->
<%
Response.Write "<html>"
%>
<body>

Does not suffer this problem because ASP does not create send the CRLF that
preceeds an inline script.

</quote>

This principal applies to code like this as well:-

%>
<!-- #include file="abcdefg.inc.asp" -->
<%

Neither CRLF sequence in the above preceeds content hence neither is sent.
Try it for yourself.
>

--
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 24 '06 #24

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

Similar topics

5
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...
0
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...
0
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...
7
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,...
6
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"...
2
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...
1
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...
10
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...
16
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.