Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > would this be a possible use of an HTTPHandler?

Reply
Thread Tools

would this be a possible use of an HTTPHandler?

 
 
Steve
Guest
Posts: n/a
 
      01-11-2004
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


 
Reply With Quote
 
 
 
 
Hermit Dave
Guest
Posts: n/a
 
      01-11-2004
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/ms...tphandler.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)

--
Regards,

HD

"Steve" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
RAMADU
Guest
Posts: n/a
 
      01-12-2004

>-----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.
 
Reply With Quote
 
RAMADU
Guest
Posts: n/a
 
      01-12-2004

>-----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.
 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      01-12-2004
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.

"Steve" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
an oddball scary kind of thing you would think would never happen richard Computer Support 4 01-31-2010 06:34 PM
if I wanted to never use innerHTML, what else would I use? Jake Barnes Javascript 50 02-13-2006 07:34 PM
Would this be possible through ASP.net ? Robbo ASP .Net 2 10-30-2003 04:06 PM
Would like some comments if possible. John Smith MCSE 1 09-10-2003 05:56 PM
would this be possible--newbe Q Ford Clan Java 1 08-21-2003 07:14 PM



Advertisments