would this be a possible use of an HTTPHandler?

S

Steve

let's say that I have a webpage with an <img> tag and it has an invalid src
attribute, that is the image it points to doesn't exist. Is there any way
to catch stuff like that and handle it? For example, if I detect a missing
image, I could instead return a NoImageAvail.jpg image instead?

Weird question and I'm not sure how to ask it, but I suspect it could be
something that could be handled somehow. Thanks.

Steve
 
H

Hermit Dave

The way i store images... most important ones are stored in the database...
as a byte array...
i extract them on db call and i check them for a null value... null would
mean not there....
if you are storing them in on hard drive... you can still use a stream
reader to read it from the hard drive into memory... instead of using a
plain vanilla <img tag>

in that case what you will need to do is check the hdd for image... if found
read it from a hard drive.. into a memory stream... and output it to client
page....

http://www.microsoft.com/belux/nl/msdn/community/columns/desmet/httphandler.mspx

this link is a good example on how to use custom http handler to create a
file that serves images....

you can then use <img src"the image serving file.ext?your params"> to fetch
the image... (plus you can use caching to image on server etc... to make it
faster)

Note: you can do away by just create an aspx page that does the job.. but
you dont need to (infact custom handler would be about 5% faster)
 
R

RAMADU

-----Original Message-----
let's say that I have a webpage with an <img> tag and it has an invalid src
attribute, that is the image it points to doesn't exist. Is there any way
to catch stuff like that and handle it? For example, if I detect a missing
image, I could instead return a NoImageAvail.jpg image instead?

Weird question and I'm not sure how to ask it, but I suspect it could be
something that could be handled somehow. Thanks.

Steve
Hi Steve,

Keep the image as a Server Control. On Page_Load(), check
if the image source, exists (by using IO and a try catch
block). On the catch event, make the image source point to
your NoImageAvail.jpg image.
NOTE: This process consumes a lot of I/O processing and
could make you page load slow esp. if you have a lot of
images.
 
R

RAMADU

-----Original Message-----
let's say that I have a webpage with an <img> tag and it has an invalid src
attribute, that is the image it points to doesn't exist. Is there any way
to catch stuff like that and handle it? For example, if I detect a missing
image, I could instead return a NoImageAvail.jpg image instead?

Weird question and I'm not sure how to ask it, but I suspect it could be
something that could be handled somehow. Thanks.

Steve
Hi Steve,

Keep the image as a Server Control. On Page_Load(), check
if the image source, exists (by using IO and a try catch
block). On the catch event, make the image source point to
your NoImageAvail.jpg image.
NOTE: This process consumes a lot of I/O processing and
could make you page load slow esp. if you have a lot of
images.
 
K

Kevin Spencer

Yes, that would most certainly be a candidate for an HttpHandler. You can
write an HttpHandler for all your image requests, and it can do much more
than just return an image when the image doesn't exist. It could modify or
generate images in any way you want on the fly, by using QueryStrings as
well.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top