Last post Nov 22, 2005 11:13 PM by Vince_Z
Nov 21, 2005 03:13 AM|BurntSky|LINK
This may be more of a browser-specific question, but here's what I'm trying to do: under certain circumstances, I need an IHttpHandler that will spit out HTML rather than an image. Lets say on a page where this applicable there sits an img tag ("<img src='dontserveme.jpg'
/>"). I have an HttpHandler set up to handle this request. In the ProcessRequest method I need to change the content type to "text/html" (I would assume) and spit out a certain string of HTML instead of the image. It works fine when I access the image file
directly, but when the request is made from the img tag I can't seem to make any browsers show the HTML rather than a broken image link.
Nov 21, 2005 04:26 AM|SomeNewKid|LINK
Say that you type the following address into the Address bar of your browser:
You and I expect that to be an image because it has a .jpg extension. However,
the browser makes *no* assumption about the type of document returned. If the response is of type "text/html", then it will display the response as an HTML web page. If the response is of type "image/jpeg", then it will display the response as a bitmap.
If the response is of type "text/plain", then it will display the response as a plain text file.
Now, let's look at the following bit of HTML:
<img src="http://www.example.com/dontserveme.jpg" />
This is exactly the same address. However, this time the browser *does* make an assumption about the type of document returned. The address is within an image element, so it expects an image response. If the response is of type "image/*", it will display
the image. If the response is of type "text/*", then it will display a broken image symbol. The browser will *not* replace the <img> tag with the returned HTML. That is not the way an HTML document works.
What sort of HTML are you trying to send back to an <img> element? If you can explain what you are trying to achieve, perhaps we can suggest an alternative approach.
Nov 21, 2005 04:31 AM|BurntSky|LINK
Nov 21, 2005 07:55 PM|SomeNewKid|LINK
I suppose I can dynamically create an image and stream it out, if need be.
Nov 22, 2005 11:13 PM|Vince_Z|LINK