473,414 Members | 1,744 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,414 software developers and data experts.

would this be a possible use of an HTTPHandler?

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
Nov 18 '05 #1
4 977
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" <st***@nowhere.com> wrote in message
news:uE**************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2
-----Original Message-----
let's say that I have a webpage with an <img> tag and it has an invalid srcattribute, that is the image it points to doesn't exist. Is there any wayto catch stuff like that and handle it? For example, if I detect a missingimage, 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 besomething 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.
Nov 18 '05 #3
-----Original Message-----
let's say that I have a webpage with an <img> tag and it has an invalid srcattribute, that is the image it points to doesn't exist. Is there any wayto catch stuff like that and handle it? For example, if I detect a missingimage, 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 besomething 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.
Nov 18 '05 #4
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" <st***@nowhere.com> wrote in message
news:uE**************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #5

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

Similar topics

2
by: Hanse Davion | last post by:
Can anyone provide some insight on what this problem could be? I have searched the web, read forums, and all the installation documentation for the dotnetnuke feeware portal from asp.net. I am...
3
by: Jed | last post by:
I have written an HttpHandler which I invoke through an ashx page. The HttpHandler does various things to process the request, then it is supposed to redirect to a confirmation page. Everything...
4
by: Igor K | last post by:
Hi all, I'm developing asp.net website. Most of the pages are aspx, but let's say, some 10% are html. For this html pages i use httphandlers to intercept calls and to perform some job on this...
4
by: Jeremy Lew | last post by:
When my HttpHandler is processing a request when installed on a particular 2003 Server machine, the Context.Session object is null. Any idea why this might be? My handler implements...
14
by: qwerty | last post by:
Hi, I am using a third party win 2003 iis 6.0 to serve my website. The web site has a httphandler which does some custom jobs. When I try to invoke the httphandler from some url call, it won't...
5
by: the4man | last post by:
Hi all! I have an app that show images that are stored in SQL Server. To show the images on screen, until now (with the "old" ASP), I use the following code: <img src="showimage.asp?id=20"...
3
by: Michael Schwarz | last post by:
Hi, I have a own HttpHandler running and configured like this in my web.config: <add verb="*" path="subfolder/*.ashx" type="Class,Assembly"/> Now, when turning cookieless Sessions on my...
5
by: zlf | last post by:
Hello, I try to use a custom HttpHandler to add something to session, then display the original page. public void ProcessRequest(HttpContext context) { context.Session = "test"; } But, a...
5
by: Author | last post by:
I followed the example at http://support.microsoft.com/kb/308001/EN-US/ and created my own HttpHandler. Here is the code: using System.Web; namespace MyNameSpace { public class...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.