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? 23 5374
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"??
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"??
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.
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.
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"??
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.
"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
"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
%>
"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?
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.
"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?
"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.
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.
"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!
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.
"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!
>
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
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.
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" -->
<%
;)
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.
"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.
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.
"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.
This discussion thread is closed Replies have been disabled for this discussion. Similar topics
5 posts
views
Thread by Phil Powell |
last post: by
|
reply
views
Thread by Lee |
last post: by
|
reply
views
Thread by Gunther Schmidl |
last post: by
|
7 posts
views
Thread by Sunny |
last post: by
|
6 posts
views
Thread by David Bowey |
last post: by
|
2 posts
views
Thread by tparks69 |
last post: by
|
1 post
views
Thread by kiergaro |
last post: by
|
10 posts
views
Thread by =?Utf-8?B?UmludSBHb3BhbGFrcmlzaG5hIFBpbGxhaQ==?= |
last post: by
|
16 posts
views
Thread by Jm.GlezdeRueda |
last post: by
| | | | | | | | | | |